Mysql ICP(翻译)
英文版原文链接
https://mariadb.com/kb/en/library/index-condition-pushdown/
ICP 全称 Index Condition Pushdown。这个特性主要是针对索引查找的优化,使得查找数据的时候,无法精确匹配的索引也会做出比较。会在存储引擎层将不满足的数据直接过滤掉。
Index Condition Pushdown is an optimization that is applied for access methods that access table data through indexes: range, ref, eq_ref,
ref_or_null, and Batched Key Access. The idea is to check part of the WHERE condition that refers to index fields (we call it Pushed Index Condition) as soon as we've accessed the index.
If the Pushed Index Condition is not satisfied, we won't need to read the whole table record.
ICP 是一种通过索访问表数据的访问方法的优化,可以优化的类型有range,ref,eq_ref,ref_or_null。只要where后面的条件是索引,那么就可以适用于这个特性。如果ICP不满足(感觉这里应该是满足),则不用访问整个表的记录。
打开和关闭ICP
SET optimizer_switch='index_condition_pushdown=off'
ICP特性是默认打开的,可以通过sql语句关闭这个特性
当ICP特性被打开之后,Explain 字段会显示 “Using index condition”
When Index Condition Pushdown is used, EXPLAIN will show "Using index condition":
MariaDB [test]> explain select * from tbl where key_col1 between 10 and 11 and key_col2 like '%foo%';
+----+-------------+-------+-------+---------------+----------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+----------+---------+------+------+-----------------------+
| 1 | SIMPLE | tbl | range | key_col1 | key_col1 | 5 | NULL | 2 | Using index condition |
+----+-------------+-------+-------+---------------+----------+---------+------+------+-----------------------+
1 row in set (0.01 sec)
The idea behind index condition pushdown 关于ICP背后的秘密
In disk-based storage engines, making an index lookup is done in two steps, like shown on the picture:
在基于磁盘的存储引擎中,完成一个索引查询需要两个步骤

第一步是读入匹配的索引记录,第二步是根据索引中的指针读取表中的记录
Index Condition Pushdown optimization tries to cut down the number of full record reads by checking whether index records satisfy part of the WHERE condition that can be checked for them:
ICP特性 尝试检测where条件中的条件是否,来减少读取整个表的数据

How much speed will be gained depends on - How many records will be filtered out - How expensive it was to read them The former depends on the query and the dataset. The latter is generally bigger when table records are on disk and/or are big, especially when they have blobs.
将获得多少速度取决于 - 多少记录将被过滤掉 - 取决于多去数据需要消耗的花费 前者取决于查询和数据集。 当表记录在磁盘上和/或是大的时候,后者通常更大,特别是当它们具有斑点时。
Mysql ICP(翻译)的更多相关文章
- MySQL ICP(Index Condition Pushdown)特性
一.SQL的where条件提取规则 在ICP(Index Condition Pushdown,索引条件下推)特性之前,必须先搞明白根据何登成大神总结出一套放置于所有SQL语句而皆准的where查询条 ...
- 《高性能Mysql》翻译错误
原文中在分区表中的一句话翻译错误,如下 应该是[扫描列a上的索引就需要扫描每一个分区内对应的索引树],英文版描述如下: ''' Suppose you define an index on a and ...
- MySQL 使用经验
本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/10 在索引中完成排序 SELECT thread_id FROM ...
- MySQL 执行计划中Extra(Using where,Using index,Using index condition,Using index,Using where)的浅析
关于如何理解MySQL执行计划中Extra列的Using where.Using Index.Using index condition,Using index,Using where这四者的区别 ...
- MySQL数据丢失讨论
原文地址:http://hatemysql.com/tag/sync_binlog/ 1. 概述 很多企业选择MySQL都会担心它的数据丢失问题,从而选择Oracle,但是其实并不十分清楚什么情况下 ...
- MYSQL—— 启动MYSQL 57 报错“The service MYSQL57 failed the most recent........等”的问题解决方式!
每天开机之后,启动MYSQL Notifier就报错,第一次出现重启电脑后解决,后面的几天老是出现,重启电脑好几次都没有解决,感觉很烦人,一定要搞定这个问题找到原因,于是有了下文....... 启动M ...
- MySQL Execution Plan--IN子查询包含超多值引发的查询异常
问题描述 版本:MySQL 5.7.24 SQL语句: SELECT wave_no, SUM(IF(picking_qty IS NULL, 0, picking_qty)) AS PICKED_Q ...
- (转)MySQL数据丢失讨论
原文地址:http://hatemysql.com/tag/sync_binlog/ 1. 概述 很多企业选择MySQL都会担心它的数据丢失问题,从而选择Oracle,但是其实并不十分清楚什么情况下 ...
- Atitit s2018.2 s2 doc list on home ntpc.docx \Atiitt uke制度体系 法律 法规 规章 条例 国王诏书.docx \Atiitt 手写文字识别 讯飞科大 语音云.docx \Atitit 代码托管与虚拟主机.docx \Atitit 企业文化 每日心灵 鸡汤 值班 发布.docx \Atitit 几大研发体系对比 Stage-Gat
Atitit s2018.2 s2 doc list on home ntpc.docx \Atiitt uke制度体系 法律 法规 规章 条例 国王诏书.docx \Atiitt 手写文字识别 ...
随机推荐
- 【HDU - 1257】最少拦截系统(贪心)
最少拦截系统 Descriptions: 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的 ...
- Hexo瞎折腾系列(3) - 添加GitHub彩带和GitHub Corner
页面右上角添加GitHub彩带 你可以在这里找到一共12种样式的GitHub彩带,复制其中的超链代码. 在themes\next\layout\_layout.swig目录下找到头部彩带相关的代码: ...
- AtCoder Regular Contest 083 E - Bichrome Tree
题目传送门:https://arc083.contest.atcoder.jp/tasks/arc083_c 题目大意: 给定一棵树,你可以给这些点任意黑白染色,并且赋上权值,现给定一个序列\(X_i ...
- h5-15-svg格式图片
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- h5-21-文件操作-读取文件内容
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 转 google 制作 邀请函
http://blog.csdn.net/adali/article/details/8315619
- DNS练习之反向解析
环境同正向解析一样. 切换到/var/named/chroot/etc目录下: 编辑named.rfc1912.zones文件,在末尾添加如下内容: [root@sishen63 etc]# vim ...
- FFmpegUtil
这几天没事研究音频玩 比如 X配音app的配音功能 录一段 pcm或者wav格式的文件 替换mp4指定位置的音频刚开始卡在 pcm混合以及pcm指定位置插入.思路 一段段的视频进行切割 用到MP4Co ...
- 成为Android高手必须掌握的8项基本要求
[1] Android操作系统概述 1. Android系统架构. 2. Android利用设计理念. 3. Android 开源知识. 4. Android 参考网站与权威信息.[2] Androi ...
- ios 从相册视频中获取视频截图
//给image添加个分类 +(UIImage *)getImage:(NSURL: *)videoURL { AVURLAsset *asset = [[AVURLAsset alloc] init ...