当前位置:网站首页>Dig deep into MySQL - resolve the difference between clustered and non clustered indexes
Dig deep into MySQL - resolve the difference between clustered and non clustered indexes
2022-06-24 23:09:00 【Little Camellia girl】
All are B+ The data structure of the tree , The leaf node of cluster index is the data node . The leaf node of the non clustered index is still the index node , There is only one pointer to the corresponding data block .
Cluster index : Put data storage and index together , The leaf node of the index structure holds the row data
Nonclustered index : Separate data from index , The leaf node of the index structure points to the corresponding position of the data
Cluster index is an index whose sequential structure is consistent with the physical structure of data storage , And the clustered index of a table can only have a unique one ; A non clustered index corresponding to a table can have multiple entries , Non clustered indexes with different requirements can be established according to the constraints of different columns ;
advantage
1、 The data can be directly obtained through the cluster index , Compared with non clustered indexes, back to table is required ( Except overlay index ) Be efficient
2、 Cluster index is very efficient for range query , Because its data is arranged by size
3、 Cluster index is suitable for sorting , Nonclustered indexes are not suitable for .
InnoDB There must be a primary key in , The primary key must be a clustered index , Do not set it manually , Will use a unique Index as primary key index , No, unique Indexes , A hidden row inside the database will be used id As a primary key index . An index created on top of a clustered index is called a secondary index , Secondary index access data always needs secondary search , Non clustered indexes are secondary indexes , Like composite index , Prefix index 、 unique index . The secondary index leaf node no longer stores the physical location of the row , It's the primary key value .
InnoDB The leaf node of the secondary index stores KEY Field plus primary key value . therefore , Through the secondary index query, the primary key value is found first , then InnoDB Then find the corresponding data block through the primary key index according to the primary key value . and MyISAM The secondary index leaf node of is a combination of column value and row number , The leaf node holds the physical address of the data . So it can be seen that MYISAM There is no difference between primary key index and secondary index , The primary key index is just one called PRIMARY The only 、 Non empty index , And MYISAM No primary key can be set in the engine .
边栏推荐
- 2022 safety officer-b certificate examination question bank and answers
- A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
- Learn more about redis' eight data types and application scenario analysis
- 剑指 Offer 42. 连续子数组的最大和
- Sword finger offer 42 Maximum sum of successive subarrays
- 倍加福(P+F)R2000修改雷达IP
- Development specification - parameter verification exception, exception return prompt section
- 剑指 Offer 13. 机器人的运动范围
- Research Report on solar battery charger industry - market status analysis and development prospect forecast
- Attackg: constructing technical knowledge graph from cyber thread intelligence reports
猜你喜欢

High level application of SQL statements in MySQL database (I)

23研考生注意啦!备考期间最容易中招的骗局,居然是它们?!
![[postgraduate entrance examination English] prepare for 2023, learn list8 words](/img/25/d1f2c2b4c0958d381db87e5ef96df9.jpg)
[postgraduate entrance examination English] prepare for 2023, learn list8 words

大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习

01_ Getting started with the spingboot framework

Servlet

laravel 宝塔安全配置

对抗训练理论分析:自适应步长快速对抗训练

【nvm】

Environment configuration | vs2017 configuring openmesh source code and environment
随机推荐
Mycms we media CMS V3.0, resource push optimization, new free template
laravel model 注意事项
03_ Spingboot core profile
剑指 Offer 13. 机器人的运动范围
Uip1.0 active sending problem understanding
非单文件组件
「ARM 架构」是一种怎样的处理器架构?
Vulnhub Vegeta: 1
vulnhub Vegeta: 1
07_SpingBoot 实现 RESTful 风格
案例解析:用「度量」提升企业研发效能|ONES Talk
Tech Talk 活动回顾|云原生 DevOps 的 Kubernetes 技巧
Selection (025) - what is the output of the following code?
vulnhub Vegeta: 1
[ROS play with turtle turtle]
推送Markdown格式信息到钉钉机器人
[text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
Research Report on market evaluation and investment direction of Chinese dermatology drugs (2022 Edition)
Financial management [3]
对抗训练理论分析:自适应步长快速对抗训练