当前位置:网站首页>Back to table query of MySQL? How to avoid it?

Back to table query of MySQL? How to avoid it?

2022-06-10 22:12:00 A little dog





Clustered and non-clustered indexes

Different cases of using index queries (1. Aggregate index 、2. Non aggregate index (2.1 Non primary key index 、2.2 In addition to non primary key indexes, they also contain non indexed fields ))

  • Query by primary key : When our query criteria are through the primary key , Because the primary key is a clustered index , At this time, data can be obtained directly from the leaf node of the index ;
  • When querying through a common index , There are two cases of scoring :
  1. select * from table where in xx =‘’ If the field of is just the index field , Then you can directly find the corresponding value in the index , Unwanted " Return to the table for query ", Direct return .
  2. select * from table where xx = ‘’ in xx If a field contains a field other than a normal index , Then the primary key information of the leaf node will be obtained through this record , After getting the primary key information, you can find the row information corresponding to the primary key in the aggregate index , This process is called back to table query .

What is return table query ?

With a normal index , And include non indexed fields , The primary key information of the leaf node will be obtained through the common index , After getting the primary key information, find the corresponding row information in the aggregate index , This process is called back to table query .

 Insert picture description here

The actual operation of query back to the table

 Insert picture description here

  1. explain select name from test; I see here that it is simply used index.
     Insert picture description here
  2. explain select name from test where name='name1'; Shows the order of execution Show through where Condition before use index.
  3. explain select * from test where name='name1'; When these two items are executed, you can also see , The following statements will be found because they cannot be found through the index , Therefore, the query operation will be performed . get data .






Please correct me if there is any mistake

原网站

版权声明
本文为[A little dog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206102049242246.html