Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Rob Sargent
On 7/26/21 9:55 AM, Alban Hertroys wrote: On 26 Jul 2021, at 17:52, Alban Hertroys wrote: Something like this: with recursive foo (id, parent, children_ids) as ( select id, parent, null::text from tree t where not exists ( select 1 from tree c where c.

Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Rob Sargent
On 7/26/21 9:55 AM, Alban Hertroys wrote: On 26 Jul 2021, at 17:52, Alban Hertroys wrote: Something like this: with recursive foo (id, parent, children_ids) as ( select id, parent, null::text from tree t where not exists ( select 1 from tree c where c.

Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Alban Hertroys
> On 26 Jul 2021, at 17:52, Alban Hertroys wrote: > Something like this: > > with recursive foo (id, parent, children_ids) as ( > select id, parent, null::text > from tree t >where not exists ( > select 1 from tree c where c.parent = t.id >) > u

Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Alban Hertroys
> On 26 Jul 2021, at 17:19, Avi Weinberg wrote: > > Hi, > > I would like to populate the children_ids column with all the ids of the > children recursively (+ grandchildren etc.) > If I do it top-bottom I will end up doing extra work since there is no need > to go all levels down if I can j

Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Rob Sargent
On 7/26/21 9:19 AM, Avi Weinberg wrote: Hi, I would like to populate the children_ids column with all the ids of the children recursively (+ grandchildren etc.) If I do it top-bottom I will end up doing extra work since there is no need to go all levels down if I can just compute my IMMEDIA

Re: Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Rob Sargent
On 7/26/21 9:19 AM, Avi Weinberg wrote: Hi, I would like to populate the children_ids column with all the ids of the children recursively (+ grandchildren etc.) If I do it top-bottom I will end up doing extra work since there is no need to go all levels down if I can just compute my IMMEDIA

Recursive Parent-Child Function Bottom Up

2021-07-26 Thread Avi Weinberg
Hi, I would like to populate the children_ids column with all the ids of the children recursively (+ grandchildren etc.) If I do it top-bottom I will end up doing extra work since there is no need to go all levels down if I can just compute my IMMEDIATE children "children_ids" and just concaten