当前位置:网站首页>Illustration of the insertion process of b+ tree
Illustration of the insertion process of b+ tree
2022-07-26 02:15:00 【Aiky WOW】
B+ Trees are common in modern databases , If we know it , It may be better for performance optimization in work !
I've been thinking about B+ What determines the height of a tree . Know I understand B+ Tree insertion process , There is a feeling of sudden enlightenment !
Some information on the Internet is disorderly , Different databases may also have pairs B+ Trees have different implementations . But everything is the same ,B+ The definition of a tree , It's roughly as follows :

To sum up ,B+ Under the tree 5 An important feature .
- B+ The tree contains 2 Kinds of nodes :
- Internal nodes ( Also called index node ) And leaf nodes .
- The root node itself can be an internal node , It can also be a leaf node .
- The minimum number of keywords in the root node can be 1 individual .
- B+ Trees and B The biggest difference in the tree is that the internal nodes do not save data , Index only , All the data ( Or record ) All stored in leaf nodes .
- m rank B+ The tree indicates that there are at most m-1 Key words ( Or internal nodes have at most m Subtree ), Order m At the same time, the maximum storage of leaf nodes is limited m-1 A record .
- In the internal node key All in order from small to large , For one of the internal nodes key, All in the left tree key All smaller than it , In the right subtree key Are greater than or equal to it . The records in the leaf node are also in accordance with key The size of .
- Each leaf node has a pointer to the adjacent leaf node , Leaf nodes themselves are linked in large order according to the size of keywords .
According to the above characteristics , Let's see B+ Tree insertion process .
1. Below is a tree 5 rank B+ Tree insertion process ,5 rank B+ The tree has the least nodes 2 individual key, most 4 individual key.

2. Insert again 3 Index keywords ,8,10,15.

3. Then insert keywords 16.
B+ Tree node key Value reached 5, Now the split condition is met . So we need to split nodes .
Insert 16 After the number of keywords exceeded the limit , So split up . When leaf nodes split , Suppose the split left node has 2 A record , Right node has 3 A record , middle key Become... In the index node key, Will become a parent node , Both split nodes point to the parent node ( Root node ).

4、 Suppose we insert 17 This keyword .

Be careful , Nodes are ordered .
5、 then , Let's insert another 18.

here , We find the node on the right , The splitting condition is satisfied , So we have to split .

Before and after division , The keywords on the node remain in order .
That's it , When we plug in again 10 After data , The assumed structure is as follows :

when , The number of keywords in the root node exceeds 4, It needs to be split . After the split , Left node 2 Key words , Right node 2 Key words , keyword 16 Go to the parent node , Point the split node to the parent node , The results are shown in the following figure .

And so on , When the inserted data meets the node split, it will be split . But after division , Keywords are ordered .
According to this insertion process , One B+ The height of the tree , How many keywords can a node store , That is, the index determines . Usually , A tree MySQL Of B+ Trees , Tree height is 3 Words , About hundreds of millions can be saved . If the height of the tree is too high , Query efficiency will be greatly reduced !
边栏推荐
- Slow query log in MySQL
- 1. Mx6ul core module serial Ethernet test (VII)
- 数仓:银行业数仓的分层架构实践
- Adruino 基础实验学习(一)
- 【2021】【论文笔记】6G技术愿景——OTFS调制技术
- 3. Upload the avatar to qiniu cloud and display it
- Implementation of Ti am335x industrial control module network and file system nfs
- [2021] [paper notes] biological effects of cell membrane under infrared and THz - effect is a phenomenon, action is a mechanism - the benefits of THz to medicine
- 增删改查业务的快速上手
- 1205 Lock wait timeout exceeded; try restarting transaction处理
猜你喜欢

Postman报Json序列化错误

Worthington papain - production of glycopeptides from purified proteoglycans (attached Literature)

What are the functions of cloud notes, and how do browsers add cloud note plug-ins

1. Mx6ul core module serial use - touch screen calibration (IX)

Wechat applet decryption and unpacking to obtain source code tutorial

MySQL transaction isolation level

I.MX6UL核心模块使用连载-eMMC读写测试 (四)

Navica tool imports remote MySQL into local MySQL database

力扣148:排序链表

Characteristics and determination of neuraminidase from Clostridium perfringens in Worthington
随机推荐
[xxl-job] xxl-job learning
SQL manual blind injection and error reporting injection
1. Mx6ul core module serial use - touch screen calibration (IX)
数仓:浅谈银行业的数仓构建实践
3. Upload the avatar to qiniu cloud and display it
Characteristics and determination of neuraminidase from Clostridium perfringens in Worthington
主键B+ Tree,二级索引B+ Tree及对应的查询过程分析
Relationship between HTC mobile official solution, s-on/s-off and super CID
(CVPR 2019) GSPN: Generative Shape Proposal Network for 3D Instance Segmentation in Point Cloud
What are the functions of cloud notes, and how do browsers add cloud note plug-ins
[2021] [paper notes] 6G technology vision - otfs modulation technology
阿里云Redis开发规范
Common shell operations in Phoenix
Bitmap这个“内存刺客”你要小心~
Build embedded development environment and FRP penetration under win
How to install opengauss manually (non om mode)
Kaggle registration method to solve the problem of man-machine verification
i. Mx6ull snvs power domain GPIO status hold verification
商业智能BI全解析,探寻BI本质与发展趋势
[paper reading] coat: CO scale conv attentional image transformers