Processing Tables containing tree-like data - Mailing list pgsql-novice

From psql-novice@netzach.co.il
Subject Processing Tables containing tree-like data
Date
Msg-id Pine.LNX.4.58.0705291945470.6674@perpetual.homelinux.org
Whole thread Raw
Responses Re: Processing Tables containing tree-like data  (Richard Broersma Jr <rabroersma@yahoo.com>)
Re: Processing Tables containing tree-like data  (Michael Glaesemann <grzm@seespotcode.net>)
Re: Processing Tables containing tree-like data  ("Burak Seydioglu" <buraks78@gmail.com>)
List pgsql-novice
Hi,

I have a table which looks like this:

id    info    parentid
0    <God>    0
1    Adam    0
2    Cain    1
3    Abel    1
4    Seth    1
5    Enosh    4
....



I am looking for a fast and efficient way of finding ALL the descendents
of any particular node, to unlimited depth.

Is there a standard database trick for doing this efficiently ? Writing
a recursive function would be extremely inefficient for repeated
queries.

Thanks,


Netzach

pgsql-novice by date:

Previous
From: Joshua
Date:
Subject: Re: problems with SELECT query results
Next
From: Richard Broersma Jr
Date:
Subject: Re: Processing Tables containing tree-like data