1 drop table if exists t1;
3 a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
5 insert into t1 (a1, a2, b, c, d) values
6 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
7 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
8 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
9 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
10 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
11 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
12 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
13 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
14 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
15 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
16 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
17 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
18 ('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
19 ('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
20 ('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
21 ('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
22 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
23 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
24 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
25 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
26 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
27 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
28 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
29 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
30 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
31 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
32 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
33 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
34 ('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
35 ('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
36 ('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
37 ('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
38 create index idx_t1_0 on t1 (a1);
39 create index idx_t1_1 on t1 (a1,a2,b,c);
40 create index idx_t1_2 on t1 (a1,a2,b);
42 Table Op Msg_type Msg_text
43 test.t1 analyze status Table is already up to date
44 drop table if exists t2;
46 a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(64) default ' '
48 insert into t2 select * from t1;
49 insert into t2 (a1, a2, b, c, d) values
50 ('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
51 ('a','a','a',NULL,'xyz'),
52 ('a','a','b',NULL,'xyz'),
53 ('a','b','a',NULL,'xyz'),
54 ('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
55 ('d','b','b',NULL,'xyz'),
56 ('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
57 ('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),
58 ('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
59 ('a','a','a',NULL,'xyz'),
60 ('a','a','b',NULL,'xyz'),
61 ('a','b','a',NULL,'xyz'),
62 ('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
63 ('d','b','b',NULL,'xyz'),
64 ('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
65 ('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz');
66 create index idx_t2_0 on t2 (a1);
67 create index idx_t2_1 on t2 (a1,a2,b,c);
68 create index idx_t2_2 on t2 (a1,a2,b);
70 Table Op Msg_type Msg_text
71 test.t2 analyze status Table is already up to date
72 drop table if exists t3;
74 a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' '
76 insert into t3 (a1, a2, b, c, d) values
77 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
78 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
79 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
80 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
81 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
82 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
83 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
84 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
85 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
86 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
87 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
88 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
89 insert into t3 (a1, a2, b, c, d) values
90 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
91 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
92 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
93 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
94 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
95 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
96 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
97 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
98 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
99 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
100 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
101 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
102 insert into t3 (a1, a2, b, c, d) values
103 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
104 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
105 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
106 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
107 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
108 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
109 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
110 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
111 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
112 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
113 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
114 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
115 insert into t3 (a1, a2, b, c, d) values
116 ('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
117 ('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
118 ('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
119 ('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
120 ('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
121 ('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
122 ('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
123 ('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
124 ('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
125 ('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
126 ('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
127 ('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
128 create index idx_t3_0 on t3 (a1);
129 create index idx_t3_1 on t3 (a1,a2,b,c);
130 create index idx_t3_2 on t3 (a1,a2,b);
132 Table Op Msg_type Msg_text
133 test.t3 analyze status Table is already up to date
134 explain select a1, min(a2) from t1 group by a1;
135 id select_type table type possible_keys key key_len ref rows Extra
136 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
137 explain select a1, max(a2) from t1 group by a1;
138 id select_type table type possible_keys key key_len ref rows Extra
139 1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
140 explain select a1, min(a2), max(a2) from t1 group by a1;
141 id select_type table type possible_keys key key_len ref rows Extra
142 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
143 explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
144 id select_type table type possible_keys key key_len ref rows Extra
145 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
146 explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
147 id select_type table type possible_keys key key_len ref rows Extra
148 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
149 explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
150 id select_type table type possible_keys key key_len ref rows Extra
151 1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by
152 explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
153 id select_type table type possible_keys key key_len ref rows Extra
154 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
155 explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
156 id select_type table type possible_keys key key_len ref rows Extra
157 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
158 explain select min(a2) from t1 group by a1;
159 id select_type table type possible_keys key key_len ref rows Extra
160 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
161 explain select a2, min(c), max(c) from t1 group by a1,a2,b;
162 id select_type table type possible_keys key key_len ref rows Extra
163 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
164 select a1, min(a2) from t1 group by a1;
170 select a1, max(a2) from t1 group by a1;
176 select a1, min(a2), max(a2) from t1 group by a1;
182 select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
183 a1 a2 b min(c) max(c)
200 select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
201 a1 a2 b max(c) min(c)
218 select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
219 a1 a2 b max(c) min(c)
240 select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
241 min(a2) a1 max(a2) min(a2) a1
246 select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
247 a1 b min(c) a1 max(c) b a2 max(c) max(c)
248 a a a111 a d111 a a d111 d111
249 a b e112 a h112 b a h112 h112
250 a a i121 a l121 a b l121 l121
251 a b m122 a p122 b b p122 p122
252 b a a211 b d211 a a d211 d211
253 b b e212 b h212 b a h212 h212
254 b a i221 b l221 a b l221 l221
255 b b m222 b p222 b b p222 p222
256 c a a311 c d311 a a d311 d311
257 c b e312 c h312 b a h312 h312
258 c a i321 c l321 a b l321 l321
259 c b m322 c p322 b b p322 p322
260 d a a411 d d411 a a d411 d411
261 d b e412 d h412 b a h412 h412
262 d a i421 d l421 a b l421 l421
263 d b m422 d p422 b b p422 p422
264 select min(a2) from t1 group by a1;
270 select a2, min(c), max(c) from t1 group by a1,a2,b;
288 explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
289 id select_type table type possible_keys key key_len ref rows Extra
290 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
291 explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
292 id select_type table type possible_keys key key_len ref rows Extra
293 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
294 explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
295 id select_type table type possible_keys key key_len ref rows Extra
296 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
297 explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
298 id select_type table type possible_keys key key_len ref rows Extra
299 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
300 explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
301 id select_type table type possible_keys key key_len ref rows Extra
302 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
303 explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
304 id select_type table type possible_keys key key_len ref rows Extra
305 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
306 explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
307 id select_type table type possible_keys key key_len ref rows Extra
308 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
309 explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
310 id select_type table type possible_keys key key_len ref rows Extra
311 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
312 explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
313 id select_type table type possible_keys key key_len ref rows Extra
314 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
315 explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
316 id select_type table type possible_keys key key_len ref rows Extra
317 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
318 explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
319 id select_type table type possible_keys key key_len ref rows Extra
320 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
321 explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
322 id select_type table type possible_keys key key_len ref rows Extra
323 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
324 explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
325 id select_type table type possible_keys key key_len ref rows Extra
326 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
327 explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
328 id select_type table type possible_keys key key_len ref rows Extra
329 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
330 explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
331 id select_type table type possible_keys key key_len ref rows Extra
332 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
333 explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
334 id select_type table type possible_keys key key_len ref rows Extra
335 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
336 explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
337 id select_type table type possible_keys key key_len ref rows Extra
338 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
339 explain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
340 id select_type table type possible_keys key key_len ref rows Extra
341 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
342 explain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
343 id select_type table type possible_keys key key_len ref rows Extra
344 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
345 explain select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
346 id select_type table type possible_keys key key_len ref rows Extra
347 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
348 explain select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
349 id select_type table type possible_keys key key_len ref rows Extra
350 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
351 explain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
352 id select_type table type possible_keys key key_len ref rows Extra
353 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
354 explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
355 id select_type table type possible_keys key key_len ref rows Extra
356 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
357 select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
358 a1 a2 b min(c) max(c)
371 select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
372 a1 a2 b min(c) max(c)
385 select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
399 select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
413 select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
414 a1 a2 b min(c) max(c)
427 select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
437 select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
438 a1 a2 b min(c) max(c)
447 select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
457 select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
458 a1 a2 b min(c) max(c)
467 select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
481 select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
495 select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
511 select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
512 a1 a2 b min(c) max(c)
527 select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
528 a1 a2 b min(c) max(c)
544 select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
562 select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
580 select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
581 a1 a2 b min(c) max(c)
598 select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
608 select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
609 a1 a2 b min(c) max(c)
618 select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
628 select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
629 a1 a2 b min(c) max(c)
638 select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
655 select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
670 explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
671 id select_type table type possible_keys key key_len ref rows Extra
672 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
673 explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
674 id select_type table type possible_keys key key_len ref rows Extra
675 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
676 explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
677 id select_type table type possible_keys key key_len ref rows Extra
678 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
679 explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
680 id select_type table type possible_keys key key_len ref rows Extra
681 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
682 explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
683 id select_type table type possible_keys key key_len ref rows Extra
684 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
685 explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
686 id select_type table type possible_keys key key_len ref rows Extra
687 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-by
688 explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
689 id select_type table type possible_keys key key_len ref rows Extra
690 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-by
691 explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
692 id select_type table type possible_keys key key_len ref rows Extra
693 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
694 explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
695 id select_type table type possible_keys key key_len ref rows Extra
696 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
697 explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
698 id select_type table type possible_keys key key_len ref rows Extra
699 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
700 explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
701 id select_type table type possible_keys key key_len ref rows Extra
702 1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
703 explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
704 id select_type table type possible_keys key key_len ref rows Extra
705 1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
706 select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
707 a1 a2 b max(c) min(c)
712 select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
718 select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
728 select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
729 a1 a2 b min(c) max(c)
738 select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
748 select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
749 a1 a2 b max(c) min(c)
755 select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
762 select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
773 select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
774 a1 a2 b min(c) max(c)
784 select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
795 select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
796 a1 a2 b max(c) min(c)
800 select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
805 explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
806 id select_type table type possible_keys key key_len ref rows Extra
807 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-by
808 explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
809 id select_type table type possible_keys key key_len ref rows Extra
810 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 5 Using where; Using index for group-by
811 explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
812 id select_type table type possible_keys key key_len ref rows Extra
813 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
814 explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
815 id select_type table type possible_keys key key_len ref rows Extra
816 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
817 explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
818 id select_type table type possible_keys key key_len ref rows Extra
819 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
820 explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
821 id select_type table type possible_keys key key_len ref rows Extra
822 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
823 select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
827 select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
831 select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
835 select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
839 select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
840 a1 a2 b min(c) max(c)
843 select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
844 a1 a2 b min(c) max(c)
847 explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
848 id select_type table type possible_keys key key_len ref rows Extra
849 1 SIMPLE t1 range NULL idx_t1_1 147 NULL # Using where; Using index for group-by
850 explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
851 id select_type table type possible_keys key key_len ref rows Extra
852 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
853 explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
854 id select_type table type possible_keys key key_len ref rows Extra
855 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
856 explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
857 id select_type table type possible_keys key key_len ref rows Extra
858 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
859 explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
860 id select_type table type possible_keys key key_len ref rows Extra
861 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
862 explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
863 id select_type table type possible_keys key key_len ref rows Extra
864 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
865 explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
866 id select_type table type possible_keys key key_len ref rows Extra
867 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
868 explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
869 id select_type table type possible_keys key key_len ref rows Extra
870 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
871 explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
872 id select_type table type possible_keys key key_len ref rows Extra
873 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
874 explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
875 id select_type table type possible_keys key key_len ref rows Extra
876 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
877 explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
878 id select_type table type possible_keys key key_len ref rows Extra
879 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
880 explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
881 id select_type table type possible_keys key key_len ref rows Extra
882 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
883 explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
884 id select_type table type possible_keys key key_len ref rows Extra
885 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
886 explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
887 id select_type table type possible_keys key key_len ref rows Extra
888 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
889 explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
890 id select_type table type possible_keys key key_len ref rows Extra
891 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
892 explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
893 id select_type table type possible_keys key key_len ref rows Extra
894 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
895 explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
896 id select_type table type possible_keys key key_len ref rows Extra
897 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
898 explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
899 id select_type table type possible_keys key key_len ref rows Extra
900 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
901 explain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
902 id select_type table type possible_keys key key_len ref rows Extra
903 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
904 explain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
905 id select_type table type possible_keys key key_len ref rows Extra
906 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
907 explain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
908 id select_type table type possible_keys key key_len ref rows Extra
909 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
910 explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
911 id select_type table type possible_keys key key_len ref rows Extra
912 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
913 explain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
914 id select_type table type possible_keys key key_len ref rows Extra
915 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
916 explain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
917 id select_type table type possible_keys key key_len ref rows Extra
918 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
919 explain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
920 id select_type table type possible_keys key key_len ref rows Extra
921 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
922 explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
923 id select_type table type possible_keys key key_len ref rows Extra
924 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
925 explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
926 id select_type table type possible_keys key key_len ref rows Extra
927 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
928 explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
929 id select_type table type possible_keys key key_len ref rows Extra
930 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
931 explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
932 id select_type table type possible_keys key key_len ref rows Extra
933 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
934 explain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
935 id select_type table type possible_keys key key_len ref rows Extra
936 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
937 explain select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
938 id select_type table type possible_keys key key_len ref rows Extra
939 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
940 select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
958 select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
959 a1 a2 b min(c) max(c)
976 select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
990 select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
991 a1 a2 b min(c) max(c)
1004 select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
1006 select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
1007 a1 a2 b min(c) max(c)
1008 select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
1022 select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
1023 a1 a2 b min(c) max(c)
1036 select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
1054 select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
1055 a1 a2 b min(c) max(c)
1072 select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
1090 select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
1091 a1 a2 b min(c) max(c)
1108 select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
1109 a1 a2 b min(c) max(c)
1118 select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
1119 a1 a2 b min(c) max(c)
1126 select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
1127 a1 a2 b min(c) max(c)
1136 select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
1137 a1 a2 b min(c) max(c)
1146 select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
1165 select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
1166 a1 a2 b min(c) max(c)
1184 select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
1198 select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
1199 a1 a2 b min(c) max(c)
1212 select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
1214 select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
1215 a1 a2 b min(c) max(c)
1216 select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
1232 select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
1233 a1 a2 b min(c) max(c)
1248 select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
1267 select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
1268 a1 a2 b min(c) max(c)
1286 select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
1306 select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
1307 a1 a2 b min(c) max(c)
1326 select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
1327 a1 a2 b min(c) max(c)
1337 select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
1338 a1 a2 b min(c) max(c)
1346 select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
1347 a1 a2 b min(c) max(c)
1357 explain select a1,a2,b,min(c),max(c) from t1
1358 where exists ( select * from t2 where t2.c = t1.c )
1360 id select_type table type possible_keys key key_len ref rows Extra
1361 1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
1362 2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1363 explain select a1,a2,b,min(c),max(c) from t1
1364 where exists ( select * from t2 where t2.c > 'b1' )
1366 id select_type table type possible_keys key key_len ref rows Extra
1367 1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
1368 2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1369 explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1370 id select_type table type possible_keys key key_len ref rows Extra
1371 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
1372 explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
1373 id select_type table type possible_keys key key_len ref rows Extra
1374 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by
1375 explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
1376 id select_type table type possible_keys key key_len ref rows Extra
1377 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
1378 explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
1379 id select_type table type possible_keys key key_len ref rows Extra
1380 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by
1381 explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
1382 id select_type table type possible_keys key key_len ref rows Extra
1383 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by
1384 explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1385 id select_type table type possible_keys key key_len ref rows Extra
1386 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
1387 explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
1388 id select_type table type possible_keys key key_len ref rows Extra
1389 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
1390 explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1391 id select_type table type possible_keys key key_len ref rows Extra
1392 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
1393 explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
1394 id select_type table type possible_keys key key_len ref rows Extra
1395 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
1396 explain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
1397 id select_type table type possible_keys key key_len ref rows Extra
1398 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
1399 explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
1400 id select_type table type possible_keys key key_len ref rows Extra
1401 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
1402 explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
1403 id select_type table type possible_keys key key_len ref rows Extra
1404 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
1405 explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1406 id select_type table type possible_keys key key_len ref rows Extra
1407 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
1408 select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1409 a1 a2 b min(c) max(c)
1416 select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
1417 a1 a2 b min(c) max(c)
1430 select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
1431 a1 a2 b min(c) max(c)
1436 select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
1441 select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
1446 select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1448 select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
1450 select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1451 a1 a2 b min(c) max(c)
1459 select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
1460 a1 a2 b min(c) max(c)
1474 select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
1475 a1 a2 b min(c) max(c)
1480 select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
1485 select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
1490 select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1492 explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1493 id select_type table type possible_keys key key_len ref rows Extra
1494 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
1495 explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1496 id select_type table type possible_keys key key_len ref rows Extra
1497 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
1498 explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1499 id select_type table type possible_keys key key_len ref rows Extra
1500 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
1501 explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1502 id select_type table type possible_keys key key_len ref rows Extra
1503 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
1504 explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1505 id select_type table type possible_keys key key_len ref rows Extra
1506 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
1507 explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1508 id select_type table type possible_keys key key_len ref rows Extra
1509 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
1510 explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1511 id select_type table type possible_keys key key_len ref rows Extra
1512 1 SIMPLE t2 index NULL idx_t2_1 163 NULL # Using where; Using index
1513 explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1514 id select_type table type possible_keys key key_len ref rows Extra
1515 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
1516 select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1524 select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1530 select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1533 select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1535 select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
1544 select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1550 select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1553 select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1555 explain select distinct a1,a2,b from t1;
1556 id select_type table type possible_keys key key_len ref rows Extra
1557 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
1558 explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
1559 id select_type table type possible_keys key key_len ref rows Extra
1560 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
1561 explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1562 id select_type table type possible_keys key key_len ref rows filtered Extra
1563 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 50.78 Using where; Using index
1565 Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b'))
1566 explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1567 id select_type table type possible_keys key key_len ref rows Extra
1568 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
1569 explain select distinct b from t1 where (a2 >= 'b') and (b = 'a');
1570 id select_type table type possible_keys key key_len ref rows Extra
1571 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
1572 explain select distinct a1,a2,b from t2;
1573 id select_type table type possible_keys key key_len ref rows Extra
1574 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by
1575 explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
1576 id select_type table type possible_keys key key_len ref rows Extra
1577 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
1578 explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1579 id select_type table type possible_keys key key_len ref rows filtered Extra
1580 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 50.61 Using where; Using index
1582 Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b'))
1583 explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1584 id select_type table type possible_keys key key_len ref rows Extra
1585 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
1586 explain select distinct b from t2 where (a2 >= 'b') and (b = 'a');
1587 id select_type table type possible_keys key key_len ref rows Extra
1588 1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index
1589 select distinct a1,a2,b from t1;
1607 select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
1613 select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1616 select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1618 select distinct b from t1 where (a2 >= 'b') and (b = 'a');
1621 select distinct a1,a2,b from t2;
1643 select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
1649 select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1652 select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1654 select distinct b from t2 where (a2 >= 'b') and (b = 'a');
1657 select distinct t_00.a1
1659 where exists ( select * from t2 where a1 = t_00.a1 );
1665 select distinct a1,a1 from t1;
1671 select distinct a2,a1,a2,a1 from t1;
1681 select distinct t1.a1,t2.a1 from t1,t2;
1703 explain select distinct a1,a2,b from t1;
1704 id select_type table type possible_keys key key_len ref rows Extra
1705 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
1706 explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1707 id select_type table type possible_keys key key_len ref rows Extra
1708 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
1709 explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1710 id select_type table type possible_keys key key_len ref rows Extra
1711 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
1712 explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1713 id select_type table type possible_keys key key_len ref rows Extra
1714 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
1715 explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1716 id select_type table type possible_keys key key_len ref rows Extra
1717 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
1718 explain select distinct a1,a2,b from t2;
1719 id select_type table type possible_keys key key_len ref rows Extra
1720 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by
1721 explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1722 id select_type table type possible_keys key key_len ref rows Extra
1723 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
1724 explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1725 id select_type table type possible_keys key key_len ref rows Extra
1726 1 SIMPLE t2 index NULL idx_t2_1 163 NULL # Using where; Using index
1727 explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1728 id select_type table type possible_keys key key_len ref rows Extra
1729 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
1730 explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1731 id select_type table type possible_keys key key_len ref rows Extra
1732 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by; Using temporary; Using filesort
1733 select distinct a1,a2,b from t1;
1751 select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1757 select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1760 select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1762 select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1765 select distinct a1,a2,b from t2;
1787 select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1793 select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
1796 select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
1798 select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
1801 explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
1802 id select_type table type possible_keys key key_len ref rows Extra
1803 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
1804 explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1805 id select_type table type possible_keys key key_len ref rows Extra
1806 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
1807 explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1808 id select_type table type possible_keys key key_len ref rows filtered Extra
1809 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
1811 Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a'))
1812 explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
1813 id select_type table type possible_keys key key_len ref rows Extra
1814 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
1815 explain extended select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
1816 id select_type table type possible_keys key key_len ref rows filtered Extra
1817 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
1819 Note 1003 select (ord(`test`.`t1`.`a1`) + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`)) AS `ord(a1) + count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a'))
1820 select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
1821 count(distinct a1,a2,b)
1823 select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
1824 count(distinct a1,a2,b,c)
1826 select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
1827 count(distinct a1,a2,b)
1829 select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
1832 select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
1833 ord(a1) + count(distinct a1,a2,b)
1835 explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
1836 id select_type table type possible_keys key key_len ref rows Extra
1837 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
1838 explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
1839 id select_type table type possible_keys key key_len ref rows Extra
1840 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
1841 explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
1842 id select_type table type possible_keys key key_len ref rows Extra
1843 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
1844 explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
1845 id select_type table type possible_keys key key_len ref rows Extra
1846 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
1847 explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
1848 id select_type table type possible_keys key key_len ref rows Extra
1849 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
1850 select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
1851 a1 a2 b concat(min(c), max(c))
1864 select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
1878 select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
1879 concat(a1,min(c)) b max(c)
1892 select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
1893 concat(a1,a2) b min(c) max(c)
1906 select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
1907 concat(ord(min(b)),ord(max(b))) min(b) max(b)
1916 explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b;
1917 id select_type table type possible_keys key key_len ref rows Extra
1918 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
1919 explain select a1,a2,b,d from t1 group by a1,a2,b;
1920 id select_type table type possible_keys key key_len ref rows Extra
1921 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
1922 explain extended select a1,a2,min(b),max(b) from t1
1923 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
1924 id select_type table type possible_keys key key_len ref rows filtered Extra
1925 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index
1927 Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
1928 explain extended select a1,a2,b,min(c),max(c) from t1
1929 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
1930 id select_type table type possible_keys key key_len ref rows filtered Extra
1931 1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
1933 Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
1934 explain extended select a1,a2,b,c from t1
1935 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
1936 id select_type table type possible_keys key key_len ref rows filtered Extra
1937 1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
1939 Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
1940 explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
1941 id select_type table type possible_keys key key_len ref rows Extra
1942 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1943 explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
1944 id select_type table type possible_keys key key_len ref rows filtered Extra
1945 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using index
1947 Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
1948 explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
1949 id select_type table type possible_keys key key_len ref rows Extra
1950 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1951 select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
1954 explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1;
1955 id select_type table type possible_keys key key_len ref rows Extra
1956 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1957 explain select a1,a2,b,min(c),max(c) from t2
1958 where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b;
1959 id select_type table type possible_keys key key_len ref rows Extra
1960 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
1961 explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c;
1962 id select_type table type possible_keys key key_len ref rows Extra
1963 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
1964 explain select a1,a2,count(a2) from t1 group by a1,a2,b;
1965 id select_type table type possible_keys key key_len ref rows Extra
1966 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
1967 explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;
1968 id select_type table type possible_keys key key_len ref rows filtered Extra
1969 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
1971 Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
1972 explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
1973 id select_type table type possible_keys key key_len ref rows filtered Extra
1974 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
1976 Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
1977 explain select distinct(a1) from t1 where ord(a2) = 98;
1978 id select_type table type possible_keys key key_len ref rows Extra
1979 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
1980 select distinct(a1) from t1 where ord(a2) = 98;
1986 explain select a1 from t1 where a2 = 'b' group by a1;
1987 id select_type table type possible_keys key key_len ref rows Extra
1988 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
1989 select a1 from t1 where a2 = 'b' group by a1;
1995 explain select distinct a1 from t1 where a2 = 'b';
1996 id select_type table type possible_keys key key_len ref rows Extra
1997 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
1998 select distinct a1 from t1 where a2 = 'b';
2004 drop table t1,t2,t3;
2005 create table t1 (c1 int not null,c2 int not null, primary key(c1,c2));
2006 insert into t1 (c1,c2) values
2007 (10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9);
2008 select distinct c1, c2 from t1 order by c2;
2019 select c1,min(c2) as c2 from t1 group by c1 order by c2;
2024 select c1,c2 from t1 group by c1,c2 order by c2;
2036 CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b));
2037 INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4);
2039 Table Op Msg_type Msg_text
2040 test.t1 optimize status OK
2041 SELECT a FROM t1 WHERE a='AA' GROUP BY a;
2044 SELECT a FROM t1 WHERE a='BB' GROUP BY a;
2047 EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;
2048 id select_type table type possible_keys key key_len ref rows Extra
2049 1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 3 Using where; Using index
2050 EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;
2051 id select_type table type possible_keys key key_len ref rows Extra
2052 1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using index
2053 SELECT DISTINCT a FROM t1 WHERE a='BB';
2056 SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%';
2059 SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a;
2064 a int(11) NOT NULL DEFAULT '0',
2065 b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '',
2067 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
2068 CREATE PROCEDURE a(x INT)
2074 SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd);
2075 INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR));
2080 SELECT a FROM t1 WHERE a=0;
2092 SELECT DISTINCT a FROM t1 WHERE a=0;
2095 SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0;
2100 CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a));
2101 INSERT INTO t1 (a) VALUES
2102 (''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
2103 ('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
2104 ('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
2105 EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
2106 id select_type table type possible_keys key key_len ref rows Extra
2107 1 SIMPLE t1 range NULL PRIMARY 66 NULL 12 Using index for group-by
2108 SELECT DISTINCT a,a FROM t1 ORDER BY a;
2113 GREATER LONDON GREATER LONDON
2114 NORTH CENTRAL NORTH CENTRAL
2115 NORTH EAST NORTH EAST
2116 NORTH WEST NORTH WEST
2118 SOUTH EAST SOUTH EAST
2119 SOUTH WEST SOUTH WEST
2122 CREATE TABLE t1 (id1 INT, id2 INT);
2123 CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);
2124 CREATE TABLE t3 (id3 INT, id4 INT);
2125 CREATE TABLE t4 (id4 INT);
2126 CREATE TABLE t5 (id5 INT, id6 INT);
2127 CREATE TABLE t6 (id6 INT);
2128 INSERT INTO t1 VALUES(1,1);
2129 INSERT INTO t2 VALUES(1,1,1);
2130 INSERT INTO t3 VALUES(1,1);
2131 INSERT INTO t4 VALUES(1);
2132 INSERT INTO t5 VALUES(1,1);
2133 INSERT INTO t6 VALUES(1);
2137 (t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
2138 ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
2139 id2 id1 id3 id5 id4 id3 id6 id5
2144 (((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
2145 ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
2146 id2 id1 id4 id3 id6 id5 id3 id5
2148 SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
2149 id2 id1 id3 id4 id6 id5 id3 id5
2152 (t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
2153 ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
2156 id2 id3 id5 id4 id3 id6 id5 id1
2159 (t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
2162 id2 id3 id5 id4 id3 id6 id5 id1
2164 DROP TABLE t1,t2,t3,t4,t5,t6;
2165 CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b));
2166 INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
2167 explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
2168 id select_type table type possible_keys key key_len ref rows Extra
2169 1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 1 Using where; Using index for group-by
2170 SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
2173 SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a;
2176 CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
2177 INSERT INTO t2 SELECT a,b,b FROM t1;
2178 explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
2179 id select_type table type possible_keys key key_len ref rows Extra
2180 1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index for group-by
2181 SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
2185 CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
2186 INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
2187 (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
2188 EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
2189 id select_type table type possible_keys key key_len ref rows Extra
2190 1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
2192 SELECT max(b), a FROM t1 GROUP BY a;
2198 SHOW STATUS LIKE 'handler_read__e%';
2202 EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
2203 id select_type table type possible_keys key key_len ref rows Extra
2204 1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
2206 CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
2207 SHOW STATUS LIKE 'handler_read__e%';
2212 SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
2218 SHOW STATUS LIKE 'handler_read__e%';
2223 (SELECT max(b), a FROM t1 GROUP BY a) UNION
2224 (SELECT max(b), a FROM t1 GROUP BY a);
2230 SHOW STATUS LIKE 'handler_read__e%';
2234 EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
2235 (SELECT max(b), a FROM t1 GROUP BY a);
2236 id select_type table type possible_keys key key_len ref rows Extra
2237 1 PRIMARY t1 range NULL a 5 NULL 8 Using index for group-by
2238 2 UNION t1 range NULL a 5 NULL 8 Using index for group-by
2239 NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
2240 EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
2241 FROM t1 AS t1_outer;
2242 id select_type table type possible_keys key key_len ref rows Extra
2243 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2244 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
2245 EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
2246 (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
2247 id select_type table type possible_keys key key_len ref rows Extra
2248 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2249 2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
2250 EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
2251 (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
2252 id select_type table type possible_keys key key_len ref rows Extra
2253 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2254 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
2255 EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
2256 a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
2257 id select_type table type possible_keys key key_len ref rows Extra
2258 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index
2259 2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
2260 EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
2261 a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
2262 id select_type table type possible_keys key key_len ref rows Extra
2263 1 PRIMARY t1_outer range NULL a 5 NULL 8 Using index for group-by
2264 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
2265 EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
2266 ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
2267 AND t1_outer1.b = t1_outer2.b;
2268 id select_type table type possible_keys key key_len ref rows Extra
2269 1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
2270 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer
2271 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
2272 EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
2273 FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
2274 id select_type table type possible_keys key key_len ref rows Extra
2275 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
2276 2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
2277 3 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
2278 CREATE TABLE t3 LIKE t1;
2280 INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
2281 SHOW STATUS LIKE 'handler_read__e%';
2287 INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
2289 SHOW STATUS LIKE 'handler_read__e%';
2294 DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
2295 SHOW STATUS LIKE 'handler_read__e%';
2300 DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
2302 ERROR 21000: Subquery returns more than 1 row
2303 SHOW STATUS LIKE 'handler_read__e%';
2307 DROP TABLE t1,t2,t3;
2308 CREATE TABLE t1 (a int, INDEX idx(a));
2309 INSERT INTO t1 VALUES
2310 (4), (2), (1), (2), (4), (2), (1), (4),
2311 (4), (2), (1), (2), (2), (4), (1), (4);
2312 EXPLAIN SELECT DISTINCT(a) FROM t1;
2313 id select_type table type possible_keys key key_len ref rows Extra
2314 1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-by
2315 SELECT DISTINCT(a) FROM t1;
2320 EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
2321 id select_type table type possible_keys key key_len ref rows Extra
2322 1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-by
2323 SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
2329 CREATE TABLE t1 (a INT, b INT);
2330 INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
2331 INSERT INTO t1 SELECT a + 1, b FROM t1;
2332 INSERT INTO t1 SELECT a + 2, b FROM t1;
2334 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
2335 id select_type table type possible_keys key key_len ref rows Extra
2336 1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
2337 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
2343 CREATE INDEX break_it ON t1 (a, b);
2345 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
2346 id select_type table type possible_keys key key_len ref rows Extra
2347 1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by
2348 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
2355 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
2356 id select_type table type possible_keys key key_len ref rows Extra
2357 1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by; Using temporary; Using filesort
2358 SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
2365 SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
2366 id select_type table type possible_keys key key_len ref rows Extra
2367 1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
2368 SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
2369 a MIN(b) MAX(b) AVG(b)
2375 create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;
2376 insert into t1 (a,b) values
2377 (0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),
2378 (0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),
2379 (1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
2380 (1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),
2381 (2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
2382 (2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),
2383 (3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
2384 (3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);
2385 insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
2445 explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
2446 id select_type table type possible_keys key key_len ref rows filtered Extra
2447 1 SIMPLE t1 range PRIMARY,index PRIMARY 4 NULL 3 100.00 Using where; Using index for group-by; Using temporary
2449 Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a`
2451 CREATE TABLE t1 (a int, b int, c int, d int,
2452 KEY foo (c,d,a,b), KEY bar (c,a,b,d));
2453 INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
2454 INSERT INTO t1 SELECT * FROM t1;
2455 INSERT INTO t1 SELECT * FROM t1;
2456 INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
2457 EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
2458 id select_type table type possible_keys key key_len ref rows Extra
2459 1 SIMPLE t1 range NULL foo 10 NULL 9 Using where; Using index for group-by
2460 SELECT DISTINCT c FROM t1 WHERE d=4;
2466 # Bug #45386: Wrong query result with MIN function in field list,
2467 # WHERE and GROUP BY clause
2469 CREATE TABLE t (a INT, b INT, INDEX (a,b));
2470 INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
2471 INSERT INTO t SELECT * FROM t;
2473 #should use range with index for group by
2475 SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
2476 id select_type table type possible_keys key key_len ref rows Extra
2477 1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
2478 #should return 1 row
2479 SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
2483 #should use range with index for group by
2485 SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
2486 id select_type table type possible_keys key key_len ref rows Extra
2487 1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
2488 #should return 1 row
2489 SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
2492 # test 3 ranges and use the middle one
2493 INSERT INTO t SELECT a, 2 FROM t;
2494 #should use range with index for group by
2496 SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
2497 id select_type table type possible_keys key key_len ref rows Extra
2498 1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
2499 #should return 1 row
2500 SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
2505 # Bug #48472: Loose index scan inappropriately chosen for some WHERE
2508 CREATE TABLE t (a INT, b INT, INDEX (a,b));
2509 INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
2510 INSERT INTO t SELECT * FROM t;
2511 SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a;
2517 # Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in
2520 CREATE TABLE t (a INT, b INT, INDEX (a,b));
2521 INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
2522 INSERT INTO t SELECT * FROM t;
2523 SELECT a, MAX(b) FROM t WHERE b GROUP BY a;
2527 CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b));
2528 INSERT INTO t1 VALUES(1,1),(2,1);
2530 Table Op Msg_type Msg_text
2531 test.t1 analyze status OK
2532 SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;
2535 SELECT a FROM t1 WHERE b=1;
2541 # Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column
2544 ## Test for NULLs allowed
2545 CREATE TABLE t1 ( a INT, KEY (a) );
2546 INSERT INTO t1 VALUES (1), (2), (3);
2548 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2549 id select_type table type possible_keys key key_len ref rows Extra
2550 x x x x x x x x x Impossible WHERE noticed after reading const tables
2551 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2555 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2556 id select_type table type possible_keys key key_len ref rows Extra
2557 x x x x x x x x x Impossible WHERE noticed after reading const tables
2558 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2562 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2563 id select_type table type possible_keys key key_len ref rows Extra
2564 x x x x x x x x x Impossible WHERE noticed after reading const tables
2565 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2569 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2570 id select_type table type possible_keys key key_len ref rows Extra
2571 x x x x x x x x x Impossible WHERE noticed after reading const tables
2572 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2576 SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
2577 id select_type table type possible_keys key key_len ref rows Extra
2578 x x x x x x x x x No matching min/max row
2579 SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
2583 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2584 id select_type table type possible_keys key key_len ref rows Extra
2585 x x x x x x x x x Impossible WHERE noticed after reading const tables
2586 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2590 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2591 id select_type table type possible_keys key key_len ref rows Extra
2592 x x x x x x x x x Impossible WHERE noticed after reading const tables
2593 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2597 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2598 id select_type table type possible_keys key key_len ref rows Extra
2599 x x x x x x x x x Impossible WHERE noticed after reading const tables
2600 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2604 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2605 id select_type table type possible_keys key key_len ref rows Extra
2606 x x x x x x x x x Impossible WHERE noticed after reading const tables
2607 x x x x x x x x x Using where; Using index
2608 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2612 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2613 id select_type table type possible_keys key key_len ref rows Extra
2614 x x x x x x x x x No matching min/max row
2615 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2618 INSERT INTO t1 VALUES (NULL), (NULL);
2620 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2621 id select_type table type possible_keys key key_len ref rows Extra
2622 x x x x x x x x x Impossible WHERE noticed after reading const tables
2623 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2627 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2628 id select_type table type possible_keys key key_len ref rows Extra
2629 x x x x x x x x x Impossible WHERE noticed after reading const tables
2630 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2634 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2635 id select_type table type possible_keys key key_len ref rows Extra
2636 x x x x x x x x x Impossible WHERE noticed after reading const tables
2637 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2641 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2642 id select_type table type possible_keys key key_len ref rows Extra
2643 x x x x x x x x x Impossible WHERE noticed after reading const tables
2644 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2648 SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
2649 id select_type table type possible_keys key key_len ref rows Extra
2650 x x x x x x x x x Select tables optimized away
2651 SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
2655 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2656 id select_type table type possible_keys key key_len ref rows Extra
2657 x x x x x x x x x Impossible WHERE noticed after reading const tables
2658 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2662 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2663 id select_type table type possible_keys key key_len ref rows Extra
2664 x x x x x x x x x Impossible WHERE noticed after reading const tables
2665 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2669 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2670 id select_type table type possible_keys key key_len ref rows Extra
2671 x x x x x x x x x Impossible WHERE noticed after reading const tables
2672 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2676 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2677 id select_type table type possible_keys key key_len ref rows Extra
2678 x x x x x x x x x Impossible WHERE noticed after reading const tables
2679 x x x x x x x x x Using where; Using index
2680 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2684 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2685 id select_type table type possible_keys key key_len ref rows Extra
2686 x x x x x x x x x Select tables optimized away
2687 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2691 ## Test for NOT NULLs
2692 CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY);
2693 INSERT INTO t1 VALUES (1), (2), (3);
2695 # NULL-safe operator test disabled for non-NULL indexed columns.
2699 # - Bug#52173: Reading NULL value from non-NULL index gives
2700 # wrong result in embedded server
2702 # - Bug#52174: Sometimes wrong plan when reading a MAX value from
2706 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2707 id select_type table type possible_keys key key_len ref rows Extra
2708 x x x x x x x x x Impossible WHERE noticed after reading const tables
2709 SELECT MIN( a ) FROM t1 WHERE a = NULL;
2713 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2714 id select_type table type possible_keys key key_len ref rows Extra
2715 x x x x x x x x x Impossible WHERE noticed after reading const tables
2716 SELECT MIN( a ) FROM t1 WHERE a <> NULL;
2720 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2721 id select_type table type possible_keys key key_len ref rows Extra
2722 x x x x x x x x x Impossible WHERE noticed after reading const tables
2723 SELECT MIN( a ) FROM t1 WHERE a > NULL;
2727 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2728 id select_type table type possible_keys key key_len ref rows Extra
2729 x x x x x x x x x Impossible WHERE noticed after reading const tables
2730 SELECT MIN( a ) FROM t1 WHERE a < NULL;
2734 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2735 id select_type table type possible_keys key key_len ref rows Extra
2736 x x x x x x x x x Impossible WHERE noticed after reading const tables
2737 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
2741 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2742 id select_type table type possible_keys key key_len ref rows Extra
2743 x x x x x x x x x Impossible WHERE noticed after reading const tables
2744 SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
2748 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2749 id select_type table type possible_keys key key_len ref rows Extra
2750 x x x x x x x x x Impossible WHERE noticed after reading const tables
2751 SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
2755 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2756 id select_type table type possible_keys key key_len ref rows Extra
2757 x x x x x x x x x Impossible WHERE noticed after reading const tables
2758 x x x x x x x x x Using where; Using index
2759 SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
2763 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2764 id select_type table type possible_keys key key_len ref rows Extra
2765 x x x x x x x x x Impossible WHERE
2766 SELECT MIN( a ) FROM t1 WHERE a IS NULL;
2771 # Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&, Item*) at
2774 CREATE TABLE t1 ( a INT, KEY (a) );
2775 INSERT INTO t1 VALUES (1), (2), (3);
2776 SELECT MIN( a ) AS min_a
2778 WHERE a > 1 AND a IS NULL