Re: DAGs and recursive queries

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Jeff Davis" <pgsql(at)j-davis(dot)com>
Cc: "paul(dot)dorman" <paul(dot)dorman(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: DAGs and recursive queries
Date: 2007-09-27 22:58:33
Message-ID: 87abr77m1y.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Jeff Davis" <pgsql(at)j-davis(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message paul.dorman 2007-09-28 03:01:24 Re: DAGs and recursive queries
Previous Message Ottavio Campana 2007-09-27 20:45:26 question about pg_dump -a