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 手写文字识别 ...
随机推荐
- IT兄弟连 JavaWeb教程 Servlet表单乱码问题
在使用原生的Servlet进行Web应用开发时经常会遇到一些中文乱码问题,造成乱码问题的原因只有一个:即客户端与服务端的字符编码不一致所导致的. 请求参数乱码问题 服务器端获取客户端传递过来的数据出现 ...
- 360安全中心:WannaCry勒索软件威胁形势分析
猫宁!!! 参考链接:http://zt.360.cn/1101061855.php?dtid=1101062360&did=210646167 这不是全文,而是重点摘要部分. 2017年5月 ...
- hdu1233 还是畅通工程 基础最小生成树
//克鲁斯卡尔 #include<iostream> #include<algorithm> using namespace std; ; struct node { int ...
- Java | 基础归纳 | set
用于存储无序(存入和取出的顺序不一定相同)元素,值不能重复.
- display:table / display:table-cell 用法
display:table 元素会作为块级表格来显示(类似table):表格前后带有换行符: display:table-cell 元素会作为表格单元格来显示(类似<td> 和 < ...
- Codeforces Round #321 (Div. 2)
水 A - Kefa and First Steps /************************************************ * Author :Running_Time ...
- 二分查找 BestCoder Round #42 1002 Gunner II
题目传送门 /* 题意:查询x的id,每次前排的树倒下 使用lower_bound ()查找高度,f[i]记录第一棵高度为x树的位置,查询后+1(因为有序) */ #include <cstdi ...
- 496 Next Greater Element I 下一个更大元素 I
给定两个没有重复元素的数组 nums1 和 nums2 ,其中nums1 是 nums2 的子集.找到 nums1 中每个元素在 nums2 中的下一个比其大的值.nums1 中数字 x 的下一个更大 ...
- Java并发——结合CountDownLatch源码、Semaphore源码及ReentrantLock源码来看AQS原理
前言: 如果说J.U.C包下的核心是什么?那我想答案只有一个就是AQS.那么AQS是什么呢?接下来让我们一起揭开AQS的神秘面纱 AQS是什么? AQS是AbstractQueuedSynchroni ...
- SpringBoot 2.x (6):使用Filter、Servlet、Listener
Filter的使用: 1.常见的默认Filter有: characterEncodingFilter hiddenHttpMethodFilter httpPutFormContentFilter r ...