B树和B+树有什么区别? [英] What are the differences between B trees and B+ trees?

查看:19
本文介绍了B树和B+树有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

b-tree中,您可以将键和数据存储在内部节点和叶节点中,但是在b+树中,您有将数据存储在仅叶节点中.

In a b-tree you can store both keys and data in the internal and leaf nodes, but in a b+ tree you have to store the data in the leaf nodes only.

在 b+ 树中执行上述操作有什么好处吗?

Is there any advantage of doing the above in a b+ tree?

为什么不到处使用 b 树而不是 b+ 树,因为直观上它们看起来要快得多?

Why not use b-trees instead of b+ trees everywhere, as intuitively they seem much faster?

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

I mean, why do you need to replicate the key (data) in a b+ tree?

推荐答案

下图有助于显示 B+ 树和 B 树之间的差异.

The image below helps show the differences between B+ trees and B trees.

B+树的优点:

  • 因为 B+ 树没有与内部节点关联的数据,所以一页内存可以容纳更多的键.因此,为了访问叶节点上的数据,将需要更少的缓存未命中.
  • B+ 树的叶节点是相互关联的,因此对一棵树中的所有对象进行完整扫描只需要一次线性遍历所有叶节点.另一方面,B 树需要遍历树中的每一层.与 B+ 叶的线性遍历相比,这种全树遍历可能会涉及更多的缓存未命中.

B 树的优势:

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

这篇关于B树和B+树有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆