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
|
SET DEFAULT_STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS z1;
create table z1 (a int, b int, c int, d int, e int, primary key (c,d), clustering key (a,b));
insert into z1 values (1,1,1,1,1), (1,2,3,4,5), (3,4,1,100,1),(3,4,1,2,3),(3,5,1,21,1),(7,8,4,2,6),(9,10,34,3,2);
insert into z1 values (-1,-1,-1,-1,-1), (-1,-2,-3,-4,-5), (-3,-4,-1,-100,-1),(-3,-4,-1,-2,-3),(-3,-5,-1,-21,-1),(-7,-8,-4,-2,-6),(-9,-10,-34,-3,-2);
select * from z1 group by a,b;
a b c d e
-9 -10 -34 -3 -2
-7 -8 -4 -2 -6
-3 -5 -1 -21 -1
-3 -4 -1 -100 -1
-1 -2 -3 -4 -5
-1 -1 -1 -1 -1
1 1 1 1 1
1 2 3 4 5
3 4 1 2 3
3 5 1 21 1
7 8 4 2 6
9 10 34 3 2
explain select a,b from z1 where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 5 Using where; Using index
select a,b from z1 where a > 1;
a b
3 4
3 4
3 5
7 8
9 10
explain select a,b from z1 where a >=1 and b > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 10 NULL 6 Using where; Using index
select a,b from z1 where a >=1 and b > 1;
a b
1 2
3 4
3 4
3 5
7 8
9 10
explain select a,b from z1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 2 Using where; Using index
select a,b from z1 where a > 3;
a b
7 8
9 10
explain select a,b from z1 where a >=3 and b > 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 10 NULL 3 Using where; Using index
select a,b from z1 where a >=3 and b > 4;
a b
3 5
7 8
9 10
select distinct a from z1;
a
-9
-7
-3
-1
1
3
7
9
DROP TABLE z1;
|