I have an application includes data which describe tree-like structures
of varying width and breadth. It is important for me to be able to
recover the node-IDs for these data trees. The goal is to be able
to recover the tree node ID list given the root node ID:
Essentially, the tables are of the form:
root-table:
root node ID
+other data
major-branch-table:
root node ID
minor-branch node ID
branch trim (whether branch is still included or not)
+other data
minor-branch table:
A-minor-branch node ID
B-minor-branch node ID
+other data
The last table enables one minor-branch to lead to another (indeterminant
depth). The data structure partly results from the way that branches
may be combined to (re)create trees of varying content -- it's not
desirable to merge these tables.
There appear to be serious performance problems with using temporary tables
(many 'execute's required), and I haven't found a way to declare an
array within a pl/pgsql function (i.e. not a part of the arguments).
I can live with the result returned as a comma-delimited string containing
all the node IDs, but the iterative searching required for reconstructing the
node list means that building the string (without a temporary table or a
working array) means iteratively parsing the string many times (though
the trees don't include any cycles).
I hope that someone will be able to suggest a suitable mechanism or
strategy for recovering the tree node lists using a pl/pgsql function.
Isn't there a better way? Hoping that someone will say "Listen, dummy,
it's obvious..."
TIA!
-frank
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://www.postgresql.org/search.mpl