当前位置:网站首页>Clustered and non clustered indexes
Clustered and non clustered indexes
2022-06-10 23:09:00 【Li_ XiaoJin】
About clustered index and non clustered index .
Clustered index is not a separate index type , It's a way of storing data . Put data storage and index together , Find the index and find the data .
Non clustered indexes are also called secondary indexes , Separate data storage from indexing , The leaf node of the index structure points to the corresponding row address of the data , The corresponding data can only be found through the address .
InnoDB in , 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 .
When a table has a clustered index , Its data rows are actually stored in the leaf nodes of the index .
Cluster index is the primary key by default , If there is no primary key defined ,InnoDB Will choose a unique non empty index instead of . If there is no such index ,InnoDB Will implicitly define a primary key as the cluster index .InnoDB Only the records gathered on the same page .
Advantages and disadvantages of clustering index , advantage :
- You can save the data together . Fewer disks I/O The number of times ;
- Data access is faster . Data and indexes are stored on the same node , Get faster than non clustered indexes ;
- Queries scanned with overlay index can directly use the primary key value of the page node .
shortcoming :
- If all the data is in memory , The advantage of clustered index is not obvious ;
- The insertion speed depends heavily on the insertion order . Insert in the order of the primary key to load the data into InnoDB The fastest way in the table ; If you do not insert in the primary key order , It is best to use after loading OPTIMIZE TABLE Order to reorganize the table ;
- Updating the clustered index is costly ;
- Insert new row based on clustered index , Or when the primary key is updated and the row needs to be moved , May face “ Page splitting ” The problem of ;
- Clustered indexes can slow down full table scans , Especially the rows are sparse , Or the data storage is discontinuous due to row splitting ;
- The secondary index may be larger than expected , Because the leaf node of the secondary index contains the primary key column of the reference row ;
- Secondary index access requires two index lookups , Not once ;
Each leaf node of the cluster index contains the primary key value 、 Business ID、 For business and MVCC Rollback pointer and all remaining columns . If the primary key is a column prefix index ,InnoDB It will also contain the complete primary key column and other remaining columns .
Use InnoDB You should insert data in primary key order as much as possible , And try to insert new rows by monotonically increasing the value of the cluster key .
Copyright: use Creative Commons signature 4.0 International license agreement to license Links:https://lixj.fun/archives/ Clustered index and non clustered index
边栏推荐
- Play electronics, poor three generations
- Vulnhub practice DC-1 target
- C automatically generates Oracle table creation statement according to excel
- Native support for the first version of arm64! Microsoft win11/10 free tool set PowerToys 0.59 release
- About the college entrance examination
- How to run Plink software -- three methods
- 数据与信息资源共享平台(七)
- [content co creation] issue 17: summer is hot and you are so sweet! Participating in the signing of Huawei cloud Xiaobian, there is always a pattern gift bag that moves you!
- DC2 of vulnhub
- 项目实训11——对数据库的定时备份
猜你喜欢

vulnhub之dc4

Niuke.com: sum of two numbers

数组、List、Set、Map、Properties依赖注入格式

【原创】医鹿APP九价HPV数据抓包分析

Display of successful cases of target customer matching data table

【原创】医鹿APP九价HPV数据抓包分析

ICML2022 | 从零开始重新审视端到端的语音到文本翻译

IP反查域名

Blue Bridge Cup_ A fool sends a letter_ recursion

MA8601 pin√pin替代汤铭FE1.1s无须更改电路板|完美替代FE1.1s方案
随机推荐
That's great. The Ministry of industry and information technology has launched an internet account with a "one click unbinding" mobile phone number, which can be called an artifact
关于高考的那些事儿
完美解码PureCodec 20220601
通达信股票开户安全吗?如何办理开户呢?
盲盒商城APP系统开发的软件特点和盲盒功能介绍
Informatics Olympiad all in one 1280: [example 9.24] skiing | openjudge noi 2.690: skiing | Luogu p1434 [show2002] skiing
集度夏一平:不是所有事都向李彦宏汇报,靠产品跟小米华为竞争
AI智能视频分析EasyCVR平台设备通道批量删除功能的开发实现
UE4 getting started with bone animation
Kubernetes binary installation (v1.20.15) (VI) deploying worknode nodes
Vulnhub's DC3
Software features and functions of the blind box mall app system development
但身示你五县非那最土zaiFKMW
【GMM+KDE】基于MATLAB的GMM和KDE核估计得目标跟踪仿真
线程池的创建
Is it safe to open a BOC securities account? Is the risk high?
IPO can't cure Weima's complications?
Web3技术栈权威指南【2022】
Is there any risk in opening an account with BOC securities? Is it safe?
smb匿名