B + trees and B- trees Introduction

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:

data structure
data structure

A, hash and binary tree

Use hash lookup is directly key-valuevery 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 .

Binary Tree
Binary 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 .

B- tree
B- tree

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
B + Tree

B + tree advantages:

  1. Single node stores more elements (so this increases the branch node, the tree becomes a chunky), so that the less number of IO query.
  2. All inquiries should look to the leaf node, query performance stability.
  3. All leaf nodes form an ordered list, to facilitate range queries.
    Source: https://blog.csdn.net/qq_35571554/article/details/82759668

Guess you like

Origin www.cnblogs.com/linyufeng/p/12120217.html