英文版原文链接

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(翻译)的更多相关文章

  1. MySQL ICP(Index Condition Pushdown)特性

    一.SQL的where条件提取规则 在ICP(Index Condition Pushdown,索引条件下推)特性之前,必须先搞明白根据何登成大神总结出一套放置于所有SQL语句而皆准的where查询条 ...

  2. 《高性能Mysql》翻译错误

    原文中在分区表中的一句话翻译错误,如下 应该是[扫描列a上的索引就需要扫描每一个分区内对应的索引树],英文版描述如下: ''' Suppose you define an index on a and ...

  3. MySQL 使用经验

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/10 在索引中完成排序 SELECT thread_id FROM ...

  4. 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这四者的区别 ...

  5. MySQL数据丢失讨论

    原文地址:http://hatemysql.com/tag/sync_binlog/ 1.  概述 很多企业选择MySQL都会担心它的数据丢失问题,从而选择Oracle,但是其实并不十分清楚什么情况下 ...

  6. MYSQL—— 启动MYSQL 57 报错“The service MYSQL57 failed the most recent........等”的问题解决方式!

    每天开机之后,启动MYSQL Notifier就报错,第一次出现重启电脑后解决,后面的几天老是出现,重启电脑好几次都没有解决,感觉很烦人,一定要搞定这个问题找到原因,于是有了下文....... 启动M ...

  7. MySQL Execution Plan--IN子查询包含超多值引发的查询异常

    问题描述 版本:MySQL 5.7.24 SQL语句: SELECT wave_no, SUM(IF(picking_qty IS NULL, 0, picking_qty)) AS PICKED_Q ...

  8. (转)MySQL数据丢失讨论

    原文地址:http://hatemysql.com/tag/sync_binlog/ 1.  概述 很多企业选择MySQL都会担心它的数据丢失问题,从而选择Oracle,但是其实并不十分清楚什么情况下 ...

  9. 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 手写文字识别   ...

随机推荐

  1. hive的使用 + hive的常用语法

    本博文的主要内容有: .hive的常用语法 .内部表 .外部表 .内部表,被drop掉,会发生什么? .外部表,被drop掉,会发生什么? .内部表和外部表的,保存的路径在哪? .用于创建一些临时表存 ...

  2. hdu 3367 Pseudoforest 最大生成树★

    #include <cstdio> #include <cstring> #include <vector> #include <algorithm> ...

  3. Jmeter之聚合报告

    1.添加线程组,添加请求接口 2.设置线程组 3.线程组右击添加—>监听器—>聚合报告

  4. Painful Bases LightOJ - 1021

    Painful Bases LightOJ - 1021 题意:给出0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F中的一些字符(不重复)还有一个进制base,求这些字符的排列形成的ba ...

  5. 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges

    题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...

  6. HTTP提交方式之PUT详细介绍及POST和PUT的区别

    Http定义了与 服务器的交互方法,其中除了一般我们用的最多的GET,POST 其实还有PUT和DELETE 根据RFC2616标准(现行的HTTP/1.1)其实还有OPTIONS,GET,HEAD, ...

  7. VMwareworkstation 12安装

    由于这篇博客中有大量截图,一个一个上传太累了,所以请点击以下链接进行查看 百度云:http://pan.baidu.com/s/1bQxPSi 这里直接粘贴文字可以,但是详细的截图贴不出来!

  8. C# 部分命名规则

    接触C#开发已经四个月,整理下C#中的命名规则: 一:变量的命名规则(和Java相似) 1.变量名由字母.数字.下划线组成 2.变量名开头只能以字母.下划线开头,不能以数字开头 3.区分大小写 4.命 ...

  9. repeater使用

    Repeater: HeaderTemplate - 在加载开始执行一遍 ItemTemplate - 有多少条数据,执行多少遍 FooterTemplate - 在加载最后执行一遍 Alternat ...

  10. 玩ztree的一段代码

    <!DOCTYPE HTML> <html lang="zh" xmlns:th="http://www.thymeleaf.org"> ...