1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 Using index
flush status;
select x,id from t force index (x) where x=0 and id=0;
x id
0 0
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
explain select y,id from t force index (x) where x=0 and id=0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 NULL
flush status;
select y,id from t force index (x) where x=0 and id=0;
y id
0 0
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
explain select x,id from t force index (x) where x=0 and id=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 Using index
flush status;
select x,id from t force index (x) where x=0 and id=1;
x id
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
explain select y,id from t force index (x)where x=0 and id=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 NULL
flush status;
select y,id from t force index(x) where x=0 and id=1;
y id
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
explain select x,id from t force index (x) where x=2 and id=3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 Using index
flush status;
select x,id from t force index (x) where x=2 and id=3;
x id
2 3
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
explain select x,id from t force index (x) where x=2 and id=0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t const x x 8 const,const 1 Using index
flush status;
select x,id from t force index (x) where x=2 and id=0;
x id
show status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
drop table t;
|