Re: uniquely indexing Celko's nested set model

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>, "General PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: uniquely indexing Celko's nested set model
Date: 2007-10-20 16:04:58
Message-ID: 8F48FBBC-5FD6-429A-B92C-3EB0E82EF34C@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 20, 2007, at 7:33 , Merlin Moncure wrote:

> On 10/19/07, Richard Broersma Jr <rabroersma(at)yahoo(dot)com> wrote:
>> Is it possible to constraint both the LEFT and RIGHT fields of a
>> record to use the same index? I am looking for a way to ensure
>> for all LEFTs and RIGHTs in a table, that is it is impossible for
>> any LEFT or RIGHT to have to same value.
>
> I found the celko's approach to be not very scalable...if you do any
> inserts at all into the tree the table will thrash terribly. Have you
> eliminated other approaches, such as arrays, ltree, etc?

I believe it's a trade off: if you're doing a lot of aggregate work
and not very many updates, nested sets works very well: adjacency
lists aren't as good for this because of the necessity of following
the hierarchy from parent to child. If your hierarchy is updated
frequently, yes, you'll have a lot of thrashing as everything above
and to the left of the update must be updated as well. AFAIK, there
isn't currently a single best solution for representing trees in SQL.

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Trevor Talbot 2007-10-20 16:40:20 Re: 8.2.3: Server crashes on Windows using Eclipse/Junit
Previous Message Magnus Hagander 2007-10-20 15:33:03 Re: 8.2.3: Server crashes on Windows using Eclipse/Junit