Search Postgresql Archives

Path to top of tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux