索引下推整个思路如下:
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 of the WHERE
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 of the WHERE
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 of the WHERE
condition that applIEs to this table. Accept or reject the row based on the test result.
举例如下:
Suppose that we have a table containing information about people and their addresses and that the table has an index defined as INDEX (zipcode,lastname,firstname)
. If we kNow a person's zipcode
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%';
people表中(zipcode,lastname,firstname)构成一个索引。
如果没有使用索引下推技术,则MysqL会通过zipcode='95054'从存储引擎中查询对应的元祖,返回到MysqL服务端,然后MysqL服务端基于lastname liKE '%etrunia%'和address liKE '%Main Street%'来判断元祖是否符合条件。
如果使用了索引下推技术,则MysqL首先会返回符合zipcode='95054'的索引,然后根据lastname liKE '%etrunia%'和address liKE '%Main Street%'来判断索引是否符合
条件。如果符合条件,则根据该索引来定位对应的元祖,如果不符合,则直接reject掉。
总结
以上是内存溢出为你收集整理的MySQL索引下推技术全部内容,希望文章能够帮你解决MySQL索引下推技术所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)