Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why not B+-Tree MongoDB

Do anyone know why MongoDB use B-Tree but not B+-Tree?

As I know most DBMS use B+-Tree. Are there any special reason for MongoDB to use B-Tree?

thanks.

like image 407
dykw Avatar asked Apr 02 '13 15:04

dykw


People also ask

What are the limitations of MongoDB?

The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.

Is not condition in MongoDB?

Definition. $not performs a logical NOT operation on the specified <operator-expression> and selects the documents that do not match the <operator-expression> . This includes documents that do not contain the field .

Is not equal to MongoDB?

MongoDB provides different types of comparison operators and inequality or not equals operator( $ne ) is one of them. This operator is used to select those documents where the value of the field does not equal to the given value. It also includes those documents that do not contain the specified field.


2 Answers

The question has confused me when I learned B/B+.Now I get some answers:

  1. mysql is a relational db, while mongo isn't. It means that we do more range operations in mysql(such as select * from xx where id > 23). So the advantages of B+ tree aren't obvious.
  2. B tree's best search time is O(1), while B+ is always O(log n). So when search some 'hot' data. B tree has a better performance.(however if you always search the data in the leaf when using B tree, it takes more disk IO times so it may not perform well.)

In my opinion, it depends on the details how mongo implements.But I am not a Mongo developer. :D

like image 66
陈Jifan Avatar answered Sep 20 '22 11:09

陈Jifan


MongoDB uses B+ by WiredTiger default storage engine.

1、https://docs.mongodb.com/manual/core/wiredtiger/

Starting in MongoDB 3.2, the WiredTiger storage engine is the default storage engine.

2、http://source.wiredtiger.com/3.2.1/tune_page_size_and_comp.html

WiredTiger maintains a table's data in memory using a data structure called a B-Tree ( B+ Tree to be specific), referring to the nodes of a B-Tree as pages. Internal pages carry only keys. The leaf pages store both keys and values.

like image 38
Font Ding Avatar answered Sep 21 '22 11:09

Font Ding