The difference between B tree and B+ tree, why Mysql uses B+ tree

The difference between B-tree and B+ tree, why Mysql uses B+ tree
Features of B-tree:
1. Node sorting
2. One node can store multiple elements, and multiple elements are also sorted.
Features of B+ tree:
1. Have the characteristics of B-tree
2. There are pointers between leaf nodes
3. Elements on non-leaf nodes are redundant on leaf nodes, that is, all elements are stored in leaf nodes and arranged in order


The Mysql index uses a B+ tree, because the index is used to speed up the query, and the B+ tree can improve the query speed by sorting the data, and then store multiple elements in one node, so that the height of the B+ tree can not be too high. In Mysql, an Innodb page is a B+ tree node, and an nnodb page defaults to 16kb, so in general, a two-layer B+ tree can store about 20 million rows of data, and then use the B+ tree leaf nodes to store all data and perform With sorting and pointers between leaf nodes, it can well support SQL statements such as full table scan and range search.

What are the Mysql locks and how to understand them
? Classification by lock granularity:
1. Row lock: lock a row of data, the lock granularity is the smallest, and the concurrency is high

2. Table lock: lock the entire table with the largest lock granularity and low concurrency

3. Gap lock: the lock is an interval
 

Guess you like

Origin blog.csdn.net/weixin_53031149/article/details/127523765