IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Hierarchical SQL
Yet another article by Celko on [link|http://www.onlamp.com/pub/a/onlamp/2004/08/05/hierarchical_sql.html|Nested Sets] for those interested. Not much new here.

What I really wanted to ask, though, is whether there's a more efficient method for calculating the level of nodes within a nested set. The following query is taking way more longer than I'd expect:
   UPDATE #Tree\n   SET lvl = (SELECT COUNT(*) \n              FROM #Tree tbl \n              WHERE (tab.lft BETWEEN tbl.lft AND tbl.rgt))\n   FROM #Tree tab

New Pre-calculate it.
I do that in the stored proc that inserts the new nodes by adding one to the level of the parent node.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New That's a better way to do it.
Unfortunately, the tree I'm dealing with can take different shapes at run time, based on access rights and another tree that gets blended in.
New Re: Pre-calculate it.
That's interesting, it's differentiation.
-drl
New Those are different nested sets.
He's using strings with the navigation information encoded within. Gumpy way to do things, IMO.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     Hierarchical SQL - (ChrisR) - (4)
         Pre-calculate it. - (admin) - (2)
             That's a better way to do it. - (ChrisR)
             Re: Pre-calculate it. - (deSitter)
         Those are different nested sets. - (admin)

No manual entry for lrpd
40 ms