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
If you want to adjust the size and number of Inno...
This article example shares the specific code for...
Demand background The project is made using Vue, ...
Pure js implements a single-click editable table ...
Table of contents 1. Content Overview 2. Concepts...
<br />The official version of Baidu Encyclop...
1. Download the MySQL installation package (there...
After installing wamp for the first time, all ser...
Recently, when using select query in a project, I...
Say it in advance We all know that Docker can ach...
Use Code Cloud to build a Git code storage wareho...
Windows Server 2008 server automatically restarts...
Isolation of process address spaces is a notable ...
In some interview experiences, you can often see ...
Table of contents 1. Introduction 2. Environment ...