MySQL index push-Down Technology and MySQL index push technology
The whole idea of index push-down is as follows:
To see how this optimization works, consider first how an index scan proceeds when Index Condition Pushdown is not used:
Get the next row, first by reading the index tuple, and then by using the index tuple to locate and read the full table row.
Test the part ofWHERE
Condition that applies to this table. Accept or reject the row based on the test result.
When Index Condition Pushdown is used, the scan proceeds like this instead:
Get the next row's index tuple (but not the full table row ).
Test the part ofWHERE
Condition that applies to this table and can be checked using only index columns. If the condition is not satisfied, proceed to the index tuple for the next row.
If the condition is satisfied, use the index tuple to locate and read the full table row.
Test the remaining part ofWHERE
Condition that applies to this table. Accept or reject the row based on the test result.
Example:
Suppose that we have a table containing information about people and their addresses and that the table has an index definedINDEX (zipcode, lastname, firstname)
. If we know a person'szipcode
Value but are not sure about the last name, we can search like this:
SELECT * FROM people WHERE zipcode='95054' AND lastname LIKE '%etrunia%' AND address LIKE '%Main Street%';
The people table (zipcode, lastname, firstname) constitutes an index.
If the index push-down technology is not used, MySQL will query the corresponding ancestor from the storage engine through zipcode = '000000' and return it to the MySQL server, then the MySQL server is based on lastname LIKE '% etrunia %' and
Address LIKE '% Main Street %' to determine whether the ancestor meets the conditions.
If index push-down technology is used, MYSQL first returns an index that complies with zipcode = '20160301, then, the lastname LIKE '% etrunia %' and address LIKE '% Main Street %' are used to determine whether the index meets the requirements.
Condition. If the condition is met, the corresponding ancestor is located based on the index. If the condition is not met, the corresponding ancestor is directly reject.