MySQL concept of index-related trees

Source: Internet
Author: User

1

Simple concept of binary search tree: Under the premise of two-tree, all the nodes on the left subtree are less than/equal to the value of their parent node, and all the points on the right subtree are greater than/

There is a high height of a node

There is the simple concept of a binary balance tree with a balanced binary tree: Under the premise of binary search tree, the maximum difference of height of two subtrees trees of any node is 1 (| bf|<=1) balance factor (BF): bf= Left dial hand tree depth-right subtree depth to maintain the balance of the binary balance tree, the most important thing is to find its smallest unbalanced tree, The smallest unbalance tree can be found in this way: find the node nearest to the insertion point and the absolute value of the balance factor is the root of the subtree, after finding the smallest unbalanced tree, it needs to be balanced, mainly depends on the rotation to achieve how to maintain the balance (3 of the smallest unbalanced tree, 3 rotation mode): A. L: BF <-1 o'clock, the parent node becomes the left node of the Node B. Right: BF> 1 o'clock, the parent node becomes the right node of the node C. left-handed

However, each node of the binary tree corresponds to a maximum of 2 sub-nodes, a lot of nodes, the height of the tree will be very large, look up to traverse the number of layers will be many, efficiency is a problem, so, B + Tree was born. B+ Tree Simple concept: A special balance of the search tree, all the record nodes are key values in order to store the same layer of leaf nodes, each leaf node with a pointer to the cohesion, the key value is small in the left, the key value is large in the right.

Leaf nodes are sequentially traversed from left to right to get the order of all key values, which is why the federated index needs to meet the "leftmost prefix match".

MySQL concept of index-related trees

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.