From: | Steve Crawford <scrawford(at)pinpointresearch(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Path to top of tree |
Date: | 2007-11-13 20:35:26 |
Message-ID: | 473A0A8E.40102@pinpointresearch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Given a table which includes tree-type information consisting of an id
and a parent_id, is there an already existing function that will return
the path to the top of the tree for a given record?
The connectby function from the contrib tablefuncs does what I want for
a whole table, but I haven't found a way to execute it in an efficient
way to get the information for a single record. A query in the form of
"select connectby(.....) where ..." will return the answer I want, but
it builds the tree on the whole table and then filters to get the record
I want which, for 5000 records, is taking about half a minute.
Before I start writing my own function, have I overlooked something
already available or some better way to invoke connectby?
Cheers,
Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Morris Goldstein | 2007-11-13 22:10:33 | Impact of table scan on shared buffers |
Previous Message | Charles Mortell | 2007-11-13 20:09:54 | Re: update record with two-column primary key |