In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces whether MongoDb uses B tree or B + tree in the tree structure. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
About B-trees and B + trees, there is a classic question on the Internet: why do MongoDb use B-trees and MySQL indexes use B + trees?
But does MongoDb really use a B-tree?
By consulting the information, I found the answer from the official website of MongoDb and the official website of WiredTiger. The description of the storage engine (Storage Engine) on MongoDb's official website says: since version 3.2 of MongoDb, it has used WiredTiger as its default storage engine.
Document address: WiredTiger Storage Engine-MongoDB Manual
From the WiredTiger official website documents, we can know that WiredTiger uses B + tree as its storage structure.
Document address: WiredTiger: Tuning page size and compression
So why is there a lot of data saying that MongoDb uses B-tree as the data structure for storage? I think there may be two reasons: one reason may be that B + Tree itself is an optimization of B-tree, so many people directly refer to B + tree as B-tree. Another reason may be that before MongoDb 3.2, the B-tree was actually used as the data structure for storage.
For these two reasons, I did not explore in depth, friends who have the answer can leave a message to discuss. But I know that no matter what the reason is, it will not affect our discussion on this issue. On the surface, we are talking about the data structures stored in MongoDb and MySQL, but in fact we are talking about the characteristics of B-tree and B + tree.
Therefore, whether MongoDb uses a B-tree or a B + tree. As long as we know the difference between B-tree and B + tree, we can choose the right data structure at the right time.
The larger feature of B-tree and B + tree is that B-tree has lower time complexity for querying specific records. On the other hand, B+ tree is more convenient for range query, and B+ tree is more flat than B-tree.
For MongoDb, it is a non-relational database and does less scope query for joined tables. If this is indeed a very typical MongoDb usage scenario, using a B-tree can actually speed up its query.
But in fact, after MongoDb 3.2, it uses the B + tree as its data structure. The B+ tree has more advantages in the scope query, it is possible that the B+ tree is more flat, allowing it to find data more quickly and speed up its search speed. It is also possible that the scope query feature of MongoDb has become more widely used.
At this point, you may be a little confused, so what is the actual situation?
In fact, I didn't find the answer myself. This is the end of my thinking, and I haven't found a better answer. Instead of being stillborn, you might as well write it down and discuss it with you. Maybe soon I will suddenly realize and understand the truth, and then I will share it with you.
At this point, another question pops up in my head: then why does MongoDb use B + trees? Instead of using a balanced binary tree? Well, the answer is actually very simple-because you need to use the feature that B-tree can load a large amount of data, otherwise it cannot query and sort such a large amount of data.
On the tree structure of the MongoDb in the end is the use of B-tree or B + tree to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.