我的数据库中有左右树,这是性能问题。我将切换到具有parentId和orderId的系统。
我正在寻找一个可以在左右树中为我提供节点索引的sql脚本。
答案 0 :(得分:1)
喜欢这个吗?
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