B树(B+Tree||B-Tree)

prospect

Listed data structures: arrays, linked lists, hash, red-black tree, B tree (B + tree, B-tree)

mysql data structure (the InnoDB engine) used in the index.

1. Exclude arrays, linked lists.

Arrays, linked lists do not support large amounts of data storage and memory consumption. Low performance.

2. exclude Hash

only a hash function to calculate the hash value. But when user_id changed, hash value produced will change, and you can not find specific data records.

And can not support the part of the joint index lookup index. It does not support range lookups.

3. exclude red-black tree

The reason:
1) when the large amount of data, too many times to read the disk.

2) waste too much time to read. (Read only once 4byte, but each disk i / O operation consumes 16K)

However hashMap just for red-black tree, because hashMap memory operation is reading fast.

For the above-mentioned problems. B + tree structure with the new

1) n-tree solves the amount of data read from the disc when times too many problems.

2) a plurality of data storage nodes.

B + tree structure just to meet the requirements, 1.n tree, 2 through a data storing node.

B+tree

Feature

B + Tree is different from the B-Tree and

  1. Non-leaf nodes only store key information.
  2. It has a chain of pointers between all leaf nodes.
  3. Data records are stored in the leaf node.

B + Tree is an optimization based on the B-Tree to make it more suitable for implementing the external memory index structure, InnoDB storage engine is to use a B + Tree index implemented its structure.

B + Tree structure

In the B + Tree, all the nodes are in accordance with the key-data records stored in the order of the leaf nodes of the same level, not only stores the key value of the leaf node information, which can greatly increase the number of key values ​​stored at each node reduced height + Tree B.

When not satisfied B + Tree structure, it will be split .

Example: 5 bands B + Tree: the pointer 5 (5 lines) four keywords (four storage)

Reference blog: https: //blog.csdn.net/hao65103940/article/details/89032538

B-Tree

B-Tree is a tree to find a balance disk storage device substandard design.

Each node includes not only the key value data, and data values. Each of the memory page is limited, if the data will result in large data for each node (i.e., a page) can store a small number of key, when a large amount of data stored will also lead to B- Tree of greater depth, increasing the disk when I query / O times, thereby affecting the query efficiency. So there have been B + Tree (an optimization of the B-Tree).

Published 29 original articles · won praise 0 · Views 2254

Guess you like

Origin blog.csdn.net/rootDream/article/details/104452170