On 8/26/07, Marc Cousin <[EMAIL PROTECTED]> wrote: > On Sunday 26 August 2007 00:52:33 demerphq wrote: [snip] > > The idea is fairly straight forward, each record has a Left and Right > > value, any children will have left and right values such that P.Left > > <= C.left and C.right <=P.right. An index on both means that full > > heirarchical queries can be done efficiently. The trade off of course > > is that insert/updates are more expensive, however if I understand it > > right the scenario we are discussing is fetch heavy, in which case > > using the nested set representation will probably be a net win. [snip] > I see what you mean, and it's very interesting if we need to build the whole > tree or a full branch very fast. > > The point is, we don't need to be able to do a full hierarchical query for > what we are working on. What we need for queries are : > give me the parent dir of current dir
This is easy with parent pointer. I think there is a way to use nested sets to do it as well, but id have to look it up, however as I said in another reply, parent pointers can be coupled with nested set representation quite happily. > give me all children dirs of current dir. If you mean *direct* children then of course this is also easy with parent pointer representation. *But* if you mean "descendents" and not "children" then this can become awkward with parent pointer representation. Afaiui, it requires N queries for each level in tree. Whereas with nested sets its a single indexable query. > Neither of those are fetch heavy, we're talking of about 10 to 1000 rows. > In fact, i think it's counterproductive to retrieve all the tree : we waste > cpu cycles on the director, in the databse server, we waste bandwidth between > the server and the client, and we waste memory on the client side. > > there is no point (I think) in retrieving all the tree of a server, as most > users will only want to retrieve some very small parts of it (typically 5 to > 10 directories, while going downwards in a precise branch of the tree where > they know the files are) > > both can be done very simply with parent pointers. If you don't need to grab a subtree then yes, PP is fine. If you do its not ideal. I guess i misunderstood the problem, i thought you wanted to get "all descendants of a given node". If not, well, apologies for the noise. :-) Yves -- perl -Mre=debug -e "/just|another|perl|hacker/" ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Bacula-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bacula-devel
