B + trees and B- trees Introduction
The main function of the database is: 存数据
and 查询数据
, how not to talk about the store, look at the focus of the query data.
Simply look at the data structure is divided:
A, hash and binary tree
Use hash lookup is directly key-value
very fast, the time complexity of O (1); using a binary tree algorithm from the point of view, is the optimal solution, the time complexity of O (logN). However, considering the problem of memory space, we can not be a one-time all the data are loaded into memory, the memory is not so great. Therefore, the underlying database is not used.
Second, disk IO
When using binary query tree height determines the number of disk IO . High tree, is the number of stages from the root to the child node. The higher the tree, the more the number of disk IO occur, the longer the time-consuming! Therefore, to reduce time-consuming, it is necessary to reduce the height of the tree .
Three, B- tree
B- tree is mainly to solve the problem of high trees, the trees become lanky chunky number. The main difference between B- and binary tree is: the intermediate node is stored in the boundary range .
Four, B + tree
B- B + Tree is a tree upgrade, the middle point of adding redundancy data , the leaf node to increase the list , supports range queries .
B + tree advantages:
- Single node stores more elements (so this increases the branch node, the tree becomes a chunky), so that the less number of IO query.
- All inquiries should look to the leaf node, query performance stability.
- All leaf nodes form an ordered list, to facilitate range queries.
Source: https://blog.csdn.net/qq_35571554/article/details/82759668