博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL索引下推技术
阅读量:6450 次
发布时间:2019-06-23

本文共 1637 字,大约阅读时间需要 5 分钟。

索引下推整个思路如下:

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掉。

 

 

转载地址:http://nwlwo.baihongyu.com/

你可能感兴趣的文章
scrollView 刷新显示在中间的问题
查看>>
tomcat配置301重定向
查看>>
Spring组件扫描<context:component-scan/>使用详解
查看>>
Orchard模块开发全接触4:深度改造前台
查看>>
如何滚动更新 Service?- 每天5分钟玩转 Docker 容器技术(102)
查看>>
Jetbrains Idea连接TFS时配置的坑
查看>>
MYSQL 中的GROUP BY 的方式 (1)(loose index scan松散扫描 tight index scan紧凑扫描)
查看>>
论文格式注意事项
查看>>
英山往事之健康第一
查看>>
复旦大学游记
查看>>
linux删除文件未释放空间问题处理
查看>>
[20151208]关于Oracle Row Lock.txt
查看>>
JavaScript中的分号插入机制
查看>>
SQL Server调优系列玩转篇三(利用索引提示(Hint)引导语句最大优化运行)
查看>>
[20160921]linux下建立samba服务器.txt
查看>>
在线教育解决方案——亿网软通“互联网+”解决方案助力教育企业
查看>>
VSTO学习笔记(五)批量编辑Excel 2010 x64
查看>>
即时编译和打包您的 Groovy 脚本(转)
查看>>
未能加载文件或程序集 Microsoft.ReportViewer.Common, Version=11.0.0.0
查看>>
嵌入式 hi3518c裸板uboot烧写、kernel烧写、fs烧写小结
查看>>