How do you get the index of a node in a left-right tree?

362 Views Asked by At

I have left-right trees in my database which are a problem for performance. I'll switch to a system with a parentId and an orderId.

I'm looking for a sql script that can give me the index of a node in a left-right tree.

1

There are 1 best solutions below

0
On BEST ANSWER

Like this?

select COUNT(treestructureid) 
from TreeStructures s,
(select leftvalue, rightvalue, treeid, ParentTreeStructureId from TreeStructures where TreeStructures.TreeStructureId = 204260)
as data
where s.LeftValue <= data.LeftValue and s.RightValue <= data.RightValue
and s.TreeId = data.TreeId and s.ParentTreeStructureId = data.ParentTreeStructureId