1
create table t1 (a int primary key);
2
insert into t1 values (1),(2),(3),(4),(100),(200);
3
explain select * from t1 order by a;
4
id select_type table type possible_keys key key_len ref rows Extra
5
1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index
6
select * from t1 order by a;
14
explain select * from t1 where a>4;
15
id select_type table type possible_keys key key_len ref rows Extra
16
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL # Using where; Using index
17
select * from t1 where a>4;
21
explain select * from t1 where a<4;
22
id select_type table type possible_keys key key_len ref rows Extra
23
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL # Using where; Using index
24
select * from t1 where a<4;
29
explain select * from t1 where a=4;
30
id select_type table type possible_keys key key_len ref rows Extra
31
1 SIMPLE t1 const PRIMARY PRIMARY 4 const # Using index
32
select * from t1 where a=4;
36
create table t1 (a int primary key, b varchar(100));
37
insert into t1 values (1, "hello"), (2, "world"), (3, "Beaker"), (4, "Cricket");
38
EXPLAIN SELECT b FROM t1 WHERE a=1;
39
id select_type table type possible_keys key key_len ref rows Extra
40
1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
41
SELECT b FROM t1 WHERE a=1;
44
EXPLAIN SELECT b FROM t1 WHERE a=2;
45
id select_type table type possible_keys key key_len ref rows Extra
46
1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
47
SELECT b FROM t1 WHERE a=2;
50
EXPLAIN SELECT b FROM t1 WHERE a=3;
51
id select_type table type possible_keys key key_len ref rows Extra
52
1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
53
SELECT b FROM t1 WHERE a=3;
56
EXPLAIN SELECT b FROM t1 WHERE a=4;
57
id select_type table type possible_keys key key_len ref rows Extra
58
1 SIMPLE t1 const PRIMARY PRIMARY 4 const #
59
SELECT b FROM t1 WHERE a=4;