当前位置:网站首页>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 .
边栏推荐
- [5gc] what is 5g slice? How does 5g slice work?
- From January to June, China's ADAS suppliers accounted for 9%, and another parts giant comprehensively laid out the new smart drive track
- LeetCode 1523. 在区间范围内统计奇数数目
- (int argc, char** argv) command line parameters in visual stdio (VS)
- jvm:类加载子系统干什么的?由什么组成?需要记住哪些八股文?
- Slam 02. overall framework
- 维度灾难 维数灾难 暂记
- 0基础编程资源大全(先收藏~慢慢看~)
- Emotion analysis model based on Bert
- Does anyone know where the retract of flinksql can be specified? Only api code settings can be seen in online materials
猜你喜欢

After being fined "paid leave" for one month, Google fired him who "loves" AI

Kubernetes Flannel:HOST-GW模式

Elementary notes of binary tree

Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.

panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
![[5gc] what is 5g slice? How does 5g slice work?](/img/8c/52ba57d6a18133e97fa00b6a7cf8bc.png)
[5gc] what is 5g slice? How does 5g slice work?

基于BERT的情感分析模型

【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯

【5G】5G中的CU和DU是什么?

维度灾难 维数灾难 暂记
随机推荐
12-GuliMall 后台管理中商品系统的品牌管理
【上位机教程】CANopen通信下一体化步进电机与台达PLC(AS228T)的应用
Flutter textfield sets the height and automatically wraps lines, and the rounded border removes the underline
[5gc] what is 5g slice? How does 5g slice work?
[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp
Flutter prevents scientific counting and removes mantissa invalid 0
mqtt send receive
Router. Push(), router. Reply(), router. Go()
[typescript] typescript common types (Part 1)
【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯
概要设计说明书
Panorama of volcanic engine cloud growth plan: 30 + plans come out together, and military development advantage areas
HCIP第十一天比较(BGP的配置、发布)
Dimension disaster dimension disaster suspense
Remote IP debugger (Practical dry goods)
Shutter cachednetworkimage fillet
Does Flink CDC only support SQL client to submit SQL scripts
HCIP第十二天笔记整理(BGP联邦、选路规则)
Incorrect use of parentdatawidget when the exception was thrown, this was the stack:
Px2rem loader converts PX into REM and adapts to mobile vant UI and other frameworks