search
HomeCommon ProblemWhat is the principle of btree index

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools