mysql5.6 索引下推 extra = using index condition
create table test1(
f_a varchar(255),
f_b varchar(255),
f_c int
)charset = utf8;
alter table test1
add f_d varchar(255) null;
create index idx_test1_acb
on test1(f_a, f_c, f_b);
建立索引
explain
select * from test1
where f_a = 'f'
and f_c >1000
and f_b = 'h';
ps
- 索引下推是MySQL的新功能(难怪看的mysql高性能【MySQL5.5版】没有看到这个内容)
- 先从(f_a, f_c, f_b)idx1中取出 f_a,f_c的索引数据,
- 再根据前面拿到的索引数据再从idx中获取f_b的数据。
- 整个过程是不用回表的。所以是能够命中索引。
- 但是神奇的是 如果我只查询(f_a,f_c)这两列 命中的竟然是type=ref,可能是跟MySQL的版本有关,按道理应该是type = range