| From: | Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: query to select a linked list |
| Date: | 2007-05-09 13:28:57 |
| Message-ID: | 20070509132857.GA18313@apartia.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Wed, May 09, 2007 at 02:24:22PM +0100, 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.
After looking around a little I came to the same conclusions.
Thanks for you help,
Cheers,
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Aaron Bono | 2007-05-09 13:29:22 | Re: query to select a linked list |
| Previous Message | Gregory Stark | 2007-05-09 13:24:22 | Re: query to select a linked list |