From: Christian H. <ch...@ng...> - 2004-07-02 17:14:12
|
On 2004-07-02, at 12.40, Martin Kamerbeek wrote: [...] > The mesurements for the Nested Set module are not consistent with the=20= > timings i posted earlier on. Please not that these values of the=20 > nested set module are taken without using the get_root method.=20 > Measuring with using get_root brings the timeing for the small tree on=20= > about 3 miliseconds. Thats still a factor 2 difference, but it's only=20= > off by 3 ms. > > The big tree with using get_root, however, has a runtime of 0.050=20 > which still differs an order of magnitude. Someone knows why this is=20= > this way? Try running timethese( 100, ...) or any other number. I'm not sure if=20 that will fix it but it=B4s worth a try. Please also try the attached benchmark and see if you get the same=20 inconsistency. [...] > >> If you don't have the time, I could whip up something by the weekend. > > If something is flawed with my method, please do so. It looks that you are pulling the hole tree, but i could be wrong. [...] >> Is there a reason to keep the the "forrest" model if we are going for=20= >> the Nested Set model? > > The way pages work in WebGUI force you to use a forrest model. Every=20= > page-root is actually a seperate tree. Those are bound together with a=20= > (non-exeistent) node with pageId=3D0. If you want to drop the forrest=20= > model, you'll end up having one (existent) 'master' page (ie. only one=20= > page root) under which alle the other pages are hung. Yes, but same result could be achieved with one root. It will also make=20= things easier when moving nodes. =46rom a performance view, the forrest=20= model is better as it will lower the number of affected rows when=20 updating. >>>> >>>> Depth also comes for free, just count nodes lft between ancestors=20= >>>> lft and rgt. >>> >>> >>> Which would take a traversal of some kind. >> >> >> Yes. >> > So it doesn't come for free, which it does when you calc the depth a=20= > creation/modification time and put it in the db as a property. It does, try this: SELECT node.*, ( COUNT(node.lft) - 1 ) AS depth FROM tree AS node, tree AS ancestor WHERE node.lft BETWEEN ancestor.lft AND ancestor.rgt GROUP BY node.lft ORDER BY node.lft --=20 Christian Hansen nGmedia +46 40 660 17 50 |