explain select * from staff where first_name='Mike'; -- yes
explain select * from staff where last_name='Hillyer'; -- no
explain select * from staff where first_name='Mike' and last_name='Hillyer'; -- yes
explain select * from staff where last_name='Hillyer' and first_name='Mike'; -- yes(内部优化)
explain select * from staff where first_name='Mike' or last_name='Hillyer'; -- no
explain select * from staff where first_name='Mike' and(last_name='Hillyer' or last_name=''); -- yes
复制代码
索引(条件)下推:即ICP,全称是Index Condition Pushdown Optimization,官网的解释在这里。我们一般叫索引下推,其实正式应该称为:索引条件下推。
怎么理解?下推什么呢? 顾名思义,Condition Pushdown,把查询条件往下推。官网的这句:
With ICP enabled, ... , the MySQL server pushes this part of the WHERE condition down to the storage engine.
翻译即是:ICP启用后,把where条件的部分从server层下推到storage engine层。
需要先了解MySQL的大概架构: