2010-11-23 5 views
0

パフォーマンスに問題がある左右の木がデータベースにあります。私はparentIdとorderIdを持つシステムに切り替えます。ノードのインデックスを左右木にどのようにして取得しますか?

私は左右のツリーにノードのインデックスを与えることができるSQLスクリプトを探しています。

+1

左右木とはなんですか?入力例と予想出力を投稿してください。 –

+0

男、tag-modified-preorder-tree-tとsearch googleを参照してください。 –

答えて

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 
関連する問題