Re: query to select a linked list

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: query to select a linked list
Date: 2007-05-09 18:03:06
Message-ID: 1178733786.7497.57.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2007-05-09 at 08:24, Gregory Stark wrote:
> "Louis-David Mitterrand" <vindex+lists-pgsql-sql(at)apartia(dot)org> writes:
>
> > Each message a unique id_forum and an id_parent pointing to the replied
> > post (empty if first post).
> >
> > How can I build an elegant query to select all messages in a thread?
>
> You would need recursive queries which Postgres doesn't support. There is a
> patch out there to add support but I don't think it's up-to-date with 8.2 and
> in any case the resulting queries can be quite intense.
>
> I would recommend you look into the contrib module named "ltree". It's easy to
> use and works well with the gist indexes. It does require changing your data
> model denormalizing it slightly which makes it hard to "reparent" children,
> but if that isn't an operation you have to support I think it makes most other
> operations you might want to do much easier to support.

Are you sure the tablefunc functions, which include both connectby and
crosstab functions, aren't up to date with 8.2? They certainly are up
to 8.1, where I'm running them right now on my workstation. They built
for 8.2 and installed, but I haven't tried using them.

I would think that connectby is at least worth looking into.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2007-05-09 18:04:01 Re: query to select a linked list
Previous Message Louis-David Mitterrand 2007-05-09 14:33:01 Re: query to select a linked list