在Joe Celko的嵌套集(修改的预订遍历)的已知限制中,随着树变大到大,性能上的标记会降低.
Vadim Tropashko提出了嵌套区间,并在本文中提供了示例和理论解释:http://arxiv.org/html/cs.DB/0401014
这是一个可行的解决方案,是否有任何可行的示例(使用任何语言)从原生数据库层抽象出来?
While I've seen examples for nested sets, I haven't seen much for nested intervals, although in theory it shouldn't be difficult to convert from one to the other. Instead of doing pre-order traversal to label the nodes, do a breadth-first recursion. The trick is to work out the most efficient way of labelling n children of a node. Since the node between a/b and c/d is (a+c)/(b+d), an ill-conditioned insert (for instance, inserting the children left to right), runs the risk of creating the same exponential growth in the index values as, for instance, using a full materialized path. It is not difficult to counteract this effect - create the new indexes one at a time, inserting each at the location that produces the lowest resulting denominator.
就性能下降而言,很大程度上取决于您打算执行的操作.仍然有一些操作需要对整个树进行完全重新标记 - 嵌套集或嵌套间隔方法都适用于很少更改的结构.如果对层次结构进行了大量的结构更改,则"标准"父子表结构可能更容易使用.还要记住,嵌套集的整数标记比间隔方法更容易一些操作(例如后代数).