当前位置:网站首页>B+ tree (3) clustered index, secondary index -- MySQL from entry to proficiency (XV)
B+ tree (3) clustered index, secondary index -- MySQL from entry to proficiency (XV)
2022-07-26 13:16:00 【User 9919783】
The last article said b+ Tree index scheme , Because use the previous dichotomy to find , The prerequisite is that the index must be next to , Inspired by the number of user records , The same directory record page as the user record real data page is established ( Indexes ), And the top three floors , The highest level is the root node , At the bottom is the leaf node , Others are non leaf nodes ,record_type by 0 Represents ordinary data page ,1 Represents the catalog record page .
B+ Tree index scheme (2) --mysql From entry to mastery ( fourteen )
Cluster index
What we introduced above b+ The tree itself is a directory , Or is itself an index , He has two characteristics :
Use the primary key value size to sort records and pages :1) The bidirectional linked list between pages is sorted by the primary key value .2) The data in the page is also connected into a single Necklace table through the primary key value .3) The directory record page is also connected into a two-way linked list through the primary key value .
B+ The leaf node of the tree stores the complete user record information , Including hidden pages .
When these two characteristics are met , This is called clustered index , All complete records are recorded in the leaf node . This does not need us to use sql Use of statement display index establish ,innoDB The engine will automatically create a clustered index for us . stay innoDB in , Cluster index is the storage method of data ( All records are in leaf nodes ), That is, index is data , Data is index .
Secondary indexes (secondary index)
The above clustered index is only used when querying the primary key , It works , So cluster index is also called primary key index . Secondary index is also called auxiliary index , Characteristics of secondary index :
Use the columns in our table c2 Sort records and pages :1) The two-way linked list between pages passes c2 Column sorting .2) The data in the page passes c2 Columns are connected into a one-way linked list .3) The directory record page is also through c2 Columns are connected into a two-way linked list .
Secondary index B+ The leaf node of the tree is not the user storage data , Only store c2 Column + His primary key .
The directory page of the secondary index is no longer the primary key + Page number , It is c2 Column + Page number .
When we cluster index queries, it is the process ?
First, the root node queries our non leaf nodes , Non leaf nodes are querying page numbers through primary keys , Find the bottom page slot by binary search , Traverse the data in the slot to find all the values we need .
The secondary index lookup process ?
First locate the root directory node to us c2 Nonleaf node , On the basis of c2 Page number corresponding to non leaf points , Find the corresponding c2 Columns and primary keys , Finally, go back to the table , Re pass c2 Query the primary key of b+ Trees , Through clustering index .
That is, when we use secondary index , When indexing , You need to traverse two b+ Trees . Then why do I need to return to the table , It's really possible to put all the data pages in c2 At the leaf node of the column , But this is related to the data redundancy of the leaf node of the component , Too much memory .
边栏推荐
- Guys, how can CDC Oracle set the reading from the specified SCN number, or how to set the read-only full archive, not to read fast
- 【5G】5G中的CU和DU是什么?
- B+树索引使用(7)匹配列前缀,匹配值范围(十九)
- 深度学习3D人体姿态估计国内外研究现状及痛点
- Why do you want to make "secret comments"?
- File upload and download performance test based on the locust framework
- 解决方案丨5G技术助力搭建智慧园区
- [typescript] typescript common types (Part 2)
- Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
- Flutter prevents scientific counting and removes mantissa invalid 0
猜你喜欢

12 brand management of commodity system in gulimall background management

我们被一个 kong 的性能 bug 折腾了一个通宵

牛客刷SQL---2
![[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp](/img/d4/7b9c7c99d46661e1be2963a342dd18.jpg)
[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp

Version of NDK matched the requested version 21.0.6113669. versions available locally: 2

高通再次「押宝」中科创达,挑战智能驾驶软硬件全栈方案

The best engineer was "forced" away by you like this!

8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇

最好的工程师,就是这样被你“逼”走的!
![[applet] why can't the onreachbottom event be triggered? (one second)](/img/da/3641040c63f6db4d227dcf2ff89919.png)
[applet] why can't the onreachbottom event be triggered? (one second)
随机推荐
12 brand management of commodity system in gulimall background management
Flutter integrated Aurora push
vector的一些实用操作
panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
B+树索引使用(8)排序使用及其注意事项(二十)
Display inline+calc realizes left, middle and right layout, and the middle is adaptive
基于C#开放式TCP通信建立与西门子PLC的socket通信示例
A college archives management system based on asp.net
B+树索引使用(6)最左原则 --mysql从入门到精通(十八)
Learn about Pinia state getters actions plugins
B+树(3)聚簇索引,二级索引 --mysql从入门到精通(十五)
B+树挑选索引(1)---mysql从入门到精通(二十二)
pomerium
基于WebRTC和WebSocket实现的聊天系统
3D modeling and rendering based on B é zier curve
2022 employment season! Adobe helps creative industry workers break through the shackles of skills and return to the source of ability
LeetCode 263.丑数
Hcip day 11 comparison (BGP configuration and release)
[5gc] what is 5g slice? How does 5g slice work?
[typescript] typescript common types (Part 2)