Re: DAGs and recursive queries - Mailing list pgsql-general

From Gregory Stark
Subject Re: DAGs and recursive queries
Date
Msg-id 87abr77m1y.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: DAGs and recursive queries  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: DAGs and recursive queries  (Jeff Davis <pgsql@j-davis.com>)
Re: DAGs and recursive queries  ("paul.dorman" <paul.dorman@gmail.com>)
List pgsql-general
"Jeff Davis" <pgsql@j-davis.com> writes:

> On Wed, 2007-09-26 at 16:54 +0100, Gregory Stark wrote:
>
>> You could check out the tablefunc contrib which includes a function called
>> connectby() which implements a kind of recursive query.
>>
>> Alternatively you might look at the ltree contrib module but that doesn't work
>> the way you describe. It denormalizes the data for very fast but less flexible
>
> Ltree seems like it might be a good option for him. What doesn't it do
> that he needs?
...
> Also, how exactly is the database denormalized by using ltree?

It keeps the same information in more than one place. Consider:

1
1.1
1.1.1

Note that all three records contain the root's id of "1". If you want to
reparent 1.1 to be 2.1 you have to know that all its children also need to be
reparented as well.

That's what he said he wanted to be able to do. In general if you have a
relatively static hierarchy something like ltree works very well but if you
have a very dynamic hierarchy where nodes move around freely it's not a very
good fit.


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

pgsql-general by date:

Previous
From: Ottavio Campana
Date:
Subject: question about pg_dump -a
Next
From: "Jan Theodore Galkowski"
Date:
Subject: usage of indexes for inner joins