星空网 > 软件开发 > 数据库

MySQL索引下推技术

索引下推整个思路如下:

To see how this optimization works, consider first how an index scan proceeds when Index Condition Pushdown is not used:

  1. 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.

  2. 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:

  1. Get the next row's index tuple (but not the full table row).

  2. 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.

  3. If the condition is satisfied, use the index tuple to locate and read the full table row.

  4. 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

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

供应链中断:https://www.goluckyvip.com/tag/3143.html
粉丝增长专家:https://www.goluckyvip.com/tag/31430.html
丰卖网:https://www.goluckyvip.com/tag/31431.html
丰卖网开店:https://www.goluckyvip.com/tag/31432.html
丰米跨境电商:https://www.goluckyvip.com/tag/31433.html
丰趣海淘:https://www.goluckyvip.com/tag/31435.html
深圳有没有比较好玩的景点 深圳有没有比较好玩的景点推荐一下:https://www.vstour.cn/a/366175.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流