Home> Common Problem> body text

What is the principle of btree index

藏色散人
Release: 2020-07-01 09:34:26
Original
4297 people have browsed it

The btree index principle is that the binary tree results in a very high tree height. The nodes that are very close logically are very far away physically and cannot take advantage of locality. The number of IOs is high and the search efficiency is low; Btree is a balanced "m -way" search tree, which can use multiple branch nodes to reduce the number of nodes experienced when querying data.

What is the principle of btree index

BTree index principle

Binary tree results in very high tree height and logically close nodes. Physically very far away, locality cannot be exploited, IO times are high, and search efficiency is low

Btree is a balanced m-way search tree, which can use multiple branch nodes (subtree nodes) to reduce queries The number of nodes that data has experienced, thereby saving access time. m is called the degree of B-Tree.

The B tree can be seen as an extension of the 2-3 search tree, that is, it allows each node to have M-1 child nodes.

Features

  • There is a root node, the root node has only one record and two children or the root node is empty;

  • The key and pointer in each node record are spaced apart from each other, and the pointer points to the child node;

  • d represents the width of the tree. Except for leaf nodes, other Each node has [d/2,d-1] records, and the keys in these records are arranged by size from left to right, and there are [d/2 1,d] children;

  • In a node, all keys in the n-th subtree are less than the n-th key in this node and greater than the n-1th key;

  • All leaf nodes must be at the same level, that is, they have the same depth;

  • Due to the characteristics of B-Tree, the algorithm for retrieving data by key in B-Tree is very intuitive: First, a binary search is performed from the root node. If found, the data of the corresponding node is returned. Otherwise, the node pointed to by the pointer of the corresponding interval is searched recursively until the node is found or the null pointer is found. The former search is successful, and the latter search fails.

Recommended: "mysql tutorial"

The above is the detailed content of What is the principle of btree index. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!