What is the difference between b-tree and b+-tree?

The B+ tree improves the B tree, so that the internal nodes are only used as indexes, and the pointer to the data record is removed.

1. In the B+ tree, only the leaf nodes will have a pointer to the record (ROWID), while in the B tree, all nodes will have it, and the index items that appear in the internal nodes will no longer appear in the leaf nodes. All leaf nodes in the B+ tree are linked together by pointers, but the B tree is not.
insert image description here

2. Advantages of the B-tree: For the data in the internal nodes, it can be obtained directly, and it is not necessary to locate according to the leaf nodes. Advantages of B+ tree: Non-leaf nodes will not carry ROWID, and more index items can be accommodated in one block. First, the height of the tree can be reduced.
insert image description here

Second, an internal node can locate more leaf nodes. The leaf nodes are connected by pointers, and the range scan will be very simple , but for the B-tree, it needs to move back and forth between the leaf nodes and internal nodes.

The internal nodes of the B+ tree store the data of the index column and the address of the next layer node, and the leaf nodes store the data of the index column and the rowId corresponding to the column data

All nodes of the B-tree store the data of the index column and the rowId corresponding to the column data

Guess you like

Origin blog.csdn.net/GBS20200720/article/details/127765956