阅读innodb icp优化文档
This commit is contained in:
@@ -31,6 +31,9 @@
|
||||
- [开启MRR优化](#开启mrr优化)
|
||||
- [mrr控制](#mrr控制)
|
||||
- [read\_rnd\_buffer\_size](#read_rnd_buffer_size)
|
||||
- [Index Condition Pushdown(ICP)](#index-condition-pushdownicp)
|
||||
- [关闭ICP](#关闭icp)
|
||||
- [开启ICP](#开启icp)
|
||||
|
||||
|
||||
# innodb索引与算法
|
||||
@@ -360,5 +363,17 @@ select * from t where key_part1 >= 1000 and key_part1 < 2000 and key_part2 = 100
|
||||
#### read_rnd_buffer_size
|
||||
`read_rnd_buffer_size`用来控制键值的缓冲区大小,当大于该值时,则执行器则对已经缓存的数据根据rowId来进行排序,并通过rowId来获取数据。该值默认为`256K`.
|
||||
|
||||
## Index Condition Pushdown(ICP)
|
||||
可以通过`optimizer_switch`中的flag来控制`ICP`是否开启,如`index_condition_pushdown`为`on`,代表icp开启。
|
||||
|
||||
例如,表`people`包含`(zip_code, last_name, first_name)`索引,执行如下语句
|
||||
```sql
|
||||
select * from people where zipcode = '95054' and last_name like '%asahi%' and address like '%street%';
|
||||
```
|
||||
|
||||
### 关闭ICP
|
||||
如果ICP优化没有开启,那么数据库首先会根据索引查询`zipcode`为95054的记录,然后查询出后再根据查询出的结果过滤where的后两个条件`last_name like '%asahi%' and address like '%street%'`。
|
||||
|
||||
### 开启ICP
|
||||
当开启ICP后,数据库会将where的部分过滤条件放在存储引擎层,在索引获取数据同时就会进行where条件的过滤。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user