当前位置:网站首页>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 .
边栏推荐
- B+树(5)myISAM简介 --mysql从入门到精通(十七)
- Mysql数据目录(3)---表数据结构myISAM(二十六)
- panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
- Remote IP debugger (Practical dry goods)
- Leetcode 1523. count odd numbers within the interval
- 【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯
- Why do you want to make "secret comments"?
- 12-GuliMall 后台管理中商品系统的品牌管理
- 被罚“带薪休假”一个月后,谷歌解雇了“爱”上 AI 的他
- 学习pinia 介绍-State-Getters-Actions-Plugins
猜你喜欢

【5G】5G中的CU和DU是什么?
![[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)

C regards type as generic type T and uses it as generic type of method

从其他文件触发pytest.main()注意事项

0基础编程资源大全(先收藏~慢慢看~)

Learn about Pinia state getters actions plugins

银行业客户体验管理现状与优化策略分析

RMII, smii, gmii, rgmii interfaces of Ethernet Driver

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

1312_适用7z命令进行压缩与解压
随机推荐
SLAM 02.整体框架
Solution 5g technology helps build smart Parks
Activity.onStop() 延迟10秒?精彩绝伦的排查历程
JSON格式执行计划(6)—mysql执行计划(五十二)
How to optimize a large number of if else [email protected] Detailed explanation of valib
12-GuliMall 后台管理中商品系统的品牌管理
牛客刷SQL---2
Create EOS account action
StreamNative 团队文化:一家“透明”的公司
1-6月中国ADAS供应商占比9% 又一家零部件巨头全面布局智驾新赛道
RMII, smii, gmii, rgmii interfaces of Ethernet Driver
Kubernetes ---- life cycle introduction of PV and PVC
Does Flink CDC only support SQL client to submit SQL scripts
Kubernetes - Introduction to PV and PVC of advanced storage
Version of NDK matched the requested version 21.0.6113669. versions available locally: 2
【上位机教程】CANopen通信下一体化步进电机与台达PLC(AS228T)的应用
HCIP第十二天笔记整理(BGP联邦、选路规则)
Dimension disaster dimension disaster suspense
Flutter prevents scientific counting and removes mantissa invalid 0
[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication