当前位置:网站首页>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 .
边栏推荐
- [Wuhan University] information sharing of the first and second postgraduate entrance examinations
- EMI的主要原因-工模电流
- 机器学习编译入门课程学习笔记第一讲 机器学习编译概述
- 03_ Spingboot core profile
- Win10 or win11 printer cannot print
- 15 lines of code using mathematical formulas in wangeditor V5
- Recommended course: workplace writing training
- 2022安全员-B证考试题库及答案
- 2022 simulated 100 questions and simulated examination of high-altitude installation, maintenance and demolition
- . Net 7 Preview 1 has been officially released
猜你喜欢

Servlet

并发之共享模型管程

Environment configuration | vs2017 configuring openmesh source code and environment

Database transaction Transanction

Memory alignment of structures

The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
Mycms we media CMS V3.0, resource push optimization, new free template

【文本数据挖掘】中文命名实体识别:HMM模型+BiLSTM_CRF模型(Pytorch)【调研与实验分析】

Epics record reference 2 -- epics process database concept
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!
随机推荐
Introduction to machine learning compilation course learning notes lesson 1 overview of machine learning compilation
. Net 7 Preview 1 has been officially released
Cases of addition, deletion, modification and search of C # learning for two years and C # import and export (de duplication)
京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习
Talk about GC mechanism often asked in interview
Research and investment strategy report on China's building steel structure anticorrosive coating industry (2022 Edition)
Epics record reference 2 -- epics process database concept
Tech talk activity review kubernetes skills of cloud native Devops
Non single file component
docker-mysql8-主从
canvas 实现图片新增水印
Selection (026) - what is the output of the following code?
[ROS play with turtle turtle]
gocolly-手册
Recommended movies: Northeast tiger, licorice pizza
Analyze the implementation process of oauth2 distributed authentication and authorization based on the source code
Cat write multiline content to file
laravel model 注意事项
laravel 消息队列
Development specification - parameter verification exception, exception return prompt section