在b-树中,您可以将键和数据存储在内部节点和叶节点中,但在b+树中,您必须仅将数据存储在叶节点中。

在b+树中这样做有什么好处吗?

为什么不在所有地方都使用b-树而不是b+树,因为直觉上它们看起来更快?

我的意思是,为什么需要在b+树中复制键(数据)?


当前回答

**

B-Tree的主要缺点是遍历键的难度 按顺序。B+树保留了的快速随机访问属性 b -树,同时也允许快速顺序访问

** 参考:Data Structures Using C//作者:Aaro M Tenenbaum

http://books.google.co.in/books?id=X0Cd1Pr2W0gC&pg=PA456&lpg=PA456&dq=drawback+of+B-Tree+is+the+difficulty+of+Traversing+the+keys+sequentially&source=bl&ots=pGcPQSEJMS&sig=F9MY7zEXYAMVKl_Sg4W-0LTRor8&hl=en&sa=X&ei=nD5AUbeeH4zwrQe12oCYAQ&ved=0CDsQ6AEwAg#v=onepage&q=drawback%20of%20B-Tree%20is%20the%20difficulty%20of%20Traversing%20the%20keys%20sequentially&f=false

其他回答

B+树尤其适用于基于块的存储(例如:硬盘)。考虑到这一点,你会得到几个优势,例如(从我的脑海中):

high fanout / low depth: that means you have to get less blocks to get to the data. with data intermingled with the pointers, each read gets less pointers, so you need more seeks to get to the data simple and consistent block storage: an inner node has N pointers, nothing else, a leaf node has data, nothing else. that makes it easy to parse, debug and even reconstruct. high key density means the top nodes are almost certainly on cache, in many cases all inner nodes get quickly cached, so only the data access has to go to disk.

数据库系统概念示例

B+树

相应的b -树

在B+树中,由于只有指针存储在内部节点中,因此它们的大小明显小于B树的内部节点(存储数据+键)。 因此,B+树的索引可以在一次磁盘读取中从外部存储中提取,处理后找到目标的位置。如果它是一个B树,那么每个决策过程都需要读取磁盘。希望我把我的观点讲清楚了!:)

下图有助于显示B+树和B树之间的区别。

B+树的优点:

Because B+ trees don't have data associated with interior nodes, more keys can fit on a page of memory. Therefore, it will require fewer cache misses in order to access data that is on a leaf node. The leaf nodes of B+ trees are linked, so doing a full scan of all objects in a tree requires just one linear pass through all the leaf nodes. A B tree, on the other hand, would require a traversal of every level in the tree. This full-tree traversal will likely involve more cache misses than the linear traversal of B+ leaves.

B树的优点:

因为B树包含每个键的数据,所以经常访问的节点可以位于更靠近根的位置,因此可以更快地访问。


**

B-Tree的主要缺点是遍历键的难度 按顺序。B+树保留了的快速随机访问属性 b -树,同时也允许快速顺序访问

** 参考:Data Structures Using C//作者:Aaro M Tenenbaum

http://books.google.co.in/books?id=X0Cd1Pr2W0gC&pg=PA456&lpg=PA456&dq=drawback+of+B-Tree+is+the+difficulty+of+Traversing+the+keys+sequentially&source=bl&ots=pGcPQSEJMS&sig=F9MY7zEXYAMVKl_Sg4W-0LTRor8&hl=en&sa=X&ei=nD5AUbeeH4zwrQe12oCYAQ&ved=0CDsQ6AEwAg#v=onepage&q=drawback%20of%20B-Tree%20is%20the%20difficulty%20of%20Traversing%20the%20keys%20sequentially&f=false