1
create table t1 (a int primary key, b int, c int, unique abcindex(a,b,c), unique bcindex(b,c));
2
insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,2,3),(7,2,4),(8,2,1);
3
explain select * from t1 force index (abcindex) where a=2 and b=2;
4
id select_type table type possible_keys key key_len ref rows Extra
5
1 SIMPLE t1 ref abcindex abcindex 9 const,const # Using where; Using index
6
select * from t1 force index (abcindex) where a=2 and b=2;
9
explain select a from t1 force index (bcindex) where b=2 and c>2;
10
id select_type table type possible_keys key key_len ref rows Extra
11
1 SIMPLE t1 range bcindex bcindex 10 NULL # Using where
12
select a from t1 force index (bcindex) where b=2 and c>2;