当前位置:网站首页>Index push down (ICP) for mysql5.6

Index push down (ICP) for mysql5.6

2022-06-13 07:33:00 A hard-working dog

MySQL Study ----ICP( Index push down )

The original address of the official website :
https://dev.mysql.com/doc/refman/8.0/en/index-condition-pushdown-optimization.html
If work :
Create a student transcript ,
Index
create index id_name on student(name);
 Insert picture description here

	explain
	SELECT *  
    FROM  school.student
	where  name>'z' and name like '%a';

One . What is? ICP

ICP The index push down function is mysql5.6 The query optimization strategy , Put what was originally server The index condition judgment made by the layer , Push down to the storage engine layer , It can reduce the number and number of times that the storage engine must access the base table MySQL The number of times the server has to access the storage engine ., Improve query efficiency

Why do I need to push down the index

There is no index push down step

  1. server The layer first calls the interface of the storage engine to locate the first secondary record that meets the interval forming the scanning interval ( This sql Next is name>‘z’)
  2. The storage engine is based on B+ After the tree index quickly locates this secondary index record , Return to the table according to the primary key value of the secondary index record , Return the complete record to server layer
  3. server The layer then judges whether other search conditions are true , If yes, send it to the client , Otherwise, skip this record , Then ask the storage engine for the next record
  4. Until all records in the scanning section are scanned
    With the next step of index push down
  5. server The layer first calls the interface of the storage engine to locate the first secondary record that meets the interval forming the scanning interval .
  6. The storage engine is based on B+ After the tree index quickly locates this secondary record , Not in a hurry to return to the table , But first judge all about name Whether the columns contained in the index are valid , That is to say name>‘z’ and name like ‘%a’
    Is it true , If not, skip the record , Go to the next index record , Report back when established .
  7. setver Then judge whether other search conditions are true , Return to the client after establishment , If not, skip , Then judge the next record of the storage engine back to the table .
  8. Until all records in the scanning section are scanned

save I/0 The place of
Because every time you perform a table return operation , You need to load a clustered index page into memory , This eliminates the need for multiple table return operations , Saved I/O.
How to know if there is an index push down
View the execution plan Extra:Using index condition
The storage engine stores the conditions for judgment
All judgment conditions related to the index
 Insert picture description here

原网站

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