Non Recursive Tree

Recommend this page to a friend!

      HTML dbtree  >  All threads  >  Non Recursive Tree  >  (Un) Subscribe thread alerts  
Subject:Non Recursive Tree
Summary:Why donīt use of lefts-rights
Messages:3
Author:Manuel Herrera
Date:2005-02-11 20:53:23
Update:2005-02-12 19:30:51
 

 


  1. Non Recursive Tree   Reply   Report abuse  
Picture of Manuel Herrera Manuel Herrera - 2005-02-11 20:53:23
The theory of lefts-rights that use this class is very brillant but has a really big weak: when the tree has a significant number of sons some actions like INSERT, DELETE or move children need to update, in most cases, all registers in the tree.

If the system has, for example, 50.000 registries, and has an averange of 10 INSERTs or DELETEs at minute (really few), your DB update 1.000.000 of fields in 500.000 registries for minute.

Is this really efficient? I doubt it.

PD: Sorry for my bad english.

  2. Re: Non Recursive Tree   Reply   Report abuse  
Picture of Jonathan Gotti Jonathan Gotti - 2005-02-12 02:28:42 - In reply to message 1 from Manuel Herrera
hi,
i'haven't benchmark this method at all but i'm sure that's this method is a real performance gain for what i use it for.
I don't think that's the best method for all kind of job, but in a recent case it was really more efficient than the recursive way because the tree was rarely modified but accessed all the time. In such kind of case i really think that's more efficient to retrieve all your tree in a single query than recurse the tree and do a query for each node.
don't you think so?

regards,
nathan

  3. Re: Non Recursive Tree   Reply   Report abuse  
Picture of Manuel Herrera Manuel Herrera - 2005-02-12 19:30:51 - In reply to message 2 from Jonathan Gotti
Hi,

Youīre right; for some cases the lefts-rights method is the most efficient. But in some operative and real problems (like a big portal with many users doing operations), the heavy work of update all registiers translate in overcharge to DB. A SELECT is the most quickly query (maybe for all RMDBS) and demmand less resources of the machine and donīt affect the hard disk (because is a read action, not a write), then I prefer to do 100 SELECT querys and donīt 1 million of UPDATES.

If the application is only for read the tree, lefts-rights is the real solution.

Iīm working now in a portal oriented for my case, many registiers and many insertions and deletions. Iīm writing a class that extract all tree in a single query, and after build the tree using two field: father and level. All work is doing by PHP. But its not perfect, this method makes many operations and store the result in twice in memory (in two properties of the class). I have a DB with 54.000 registiers and work fine, but I want to prove it in a heavy test.

bye

 
For more information send a message to info at phpclasses dot org.