Index TypeClustered index: Leaf nodes store row records, and each table must have at least one clustered index. Using a clustered index query will be very fast because you can directly locate the row record. Ordinary index: secondary index, index other than the clustered index, that is, non-clustered index. The leaf nodes of ordinary indexes store the values of the primary key (clustered index). Clustered index recursion rules:
Index structureid is the primary key, so it is a clustered index, and its leaf nodes store the data of the corresponding row records. Non-Clustered Index Clustered index query If the query condition is the primary key (clustered index), you only need to scan the B+ tree once to locate the row record data to be found through the clustered index. For example: Nonclustered index queryIf the query condition is a common index (non-clustered index), the B+ tree needs to be scanned twice. The first scan locates the value of the clustered index through the common index, and then the second scan locates the row record data to be found through the value of the clustered index. For example:
First, locate the clustered index value through the value of the ordinary index, and then locate the row record data through the value of the clustered index. It is necessary to scan the index B+ tree twice, and its performance is lower than scanning the index tree once. Index CoveringAll column data required by SQL can be obtained on one index tree without returning to the table, which is faster. For example: Query using id, age, name:
Add a joint index to the table: Explain analysis: At this time, the fields age and name are the composite index idx_age_name. The values of the queried fields id, age, and name are just in the index tree. It is only necessary to scan the composite index B+ tree once. This is how index coverage is achieved. At this time, the Extra field is Using index, which means that index coverage is used. Pagination query (not using index): After adding an index, you can use it to quickly search. SummarizeThis is the end of this article about table return and index coverage in MySQL. For more relevant MySQL table return and index coverage content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: HTML blockquote tag usage and beautification
>>: Summary of CSS counter and content
var numA = 0.1; var numB = 0.2; alert( numA + num...
nginx is our most commonly used server, often use...
environment System: Ubuntu 18.04 Software: qt5.12...
1. Abnormal performance of Docker startup: 1. The...
Preface Query optimization is not something that ...
This tutorial shares the detailed steps of instal...
On the mobile side, flex layout is very useful. I...
Table of contents 1. Hash table principle 2. The ...
I won't go into details about how important b...
First, we will introduce how (1) MySQL 5.7 has a ...
(1) Reduce HTTP requests. (Merge resource files a...
Need to export the fields and properties of the t...
Linux and Unix are multi-user operating systems, ...
Preface This article mainly introduces the releva...
Many tables in MySQL contain columns that can be ...