在b-树中,您可以将键和数据存储在内部节点和叶节点中,但在b+树中,您必须仅将数据存储在叶节点中。
在b+树中这样做有什么好处吗?
为什么不在所有地方都使用b-树而不是b+树,因为直觉上它们看起来更快?
我的意思是,为什么需要在b+树中复制键(数据)?
在b-树中,您可以将键和数据存储在内部节点和叶节点中,但在b+树中,您必须仅将数据存储在叶节点中。
在b+树中这样做有什么好处吗?
为什么不在所有地方都使用b-树而不是b+树,因为直觉上它们看起来更快?
我的意思是,为什么需要在b+树中复制键(数据)?
当前回答
B+树是一种平衡的树,其中从树的根到叶子的每条路径都是相同的长度,树的每个非叶子节点都有[n/2]到[n]个子节点,其中n对于特定的树是固定的。它包含索引页和数据页。 二叉树的每个父节点只有两个子节点,而B+树的每个父节点可以有不同数量的子节点
其他回答
在B+树中,由于只有指针存储在内部节点中,因此它们的大小明显小于B树的内部节点(存储数据+键)。 因此,B+树的索引可以在一次磁盘读取中从外部存储中提取,处理后找到目标的位置。如果它是一个B树,那么每个决策过程都需要读取磁盘。希望我把我的观点讲清楚了!:)
B+树是一种平衡的树,其中从树的根到叶子的每条路径都是相同的长度,树的每个非叶子节点都有[n/2]到[n]个子节点,其中n对于特定的树是固定的。它包含索引页和数据页。 二叉树的每个父节点只有两个子节点,而B+树的每个父节点可以有不同数量的子节点
In a B tree search keys and data are stored in internal or leaf nodes. But in a B+-tree data is stored only in leaf nodes. Full scan of a B+ tree is very easy because all data are found in leaf nodes. Full scan of a B tree requires a full traversal. In a B tree, data may be found in leaf nodes or internal nodes. Deletion of internal nodes is very complicated. In a B+ tree, data is only found in leaf nodes. Deletion of leaf nodes is easy. Insertion in B tree is more complicated than B+ tree. B+ trees store redundant search keys but B tree has no redundant value. In a B+ tree, leaf node data is ordered as a sequential linked list but in a B tree the leaf node cannot be stored using a linked list. Many database systems' implementations prefer the structural simplicity of a B+ tree.
B+树相对于B树的主要优点是,它们允许您通过删除指向数据的指针来打包更多指向其他节点的指针,从而增加扇出并潜在地降低树的深度。
缺点是,当您可能在内部节点中找到匹配时,无法提前退出。但由于这两种数据结构都有巨大的扇出,绝大多数匹配都将在叶节点上,这使得B+树的平均效率更高。
B+树的一个可能的用途是它适用于各种情况 哪里的树长得太大,以至于它不适合可用 内存。因此,您通常期望执行多个I/O。 B+树确实经常被使用,即使它实际上适合 内存,然后你的缓存管理器可能会永久保存它。但 这是一个特殊的情况,而不是一般的情况,缓存策略是 与B+树的维护分开。
另外,在B+树中,叶子页以 一个链表(或双链表),用于优化遍历 (用于范围搜索、排序等)。所以指针的数量是 所使用的特定算法的函数。