 Backport of:
revno: 2876.47.174
revision-id: jorgen.loland@oracle.com-20110519120355-qn7eprkad9jqwu5j
parent: mayank.prasad@oracle.com-20110518143645-bdxv4udzrmqsjmhq
committer: Jorgen Loland <jorgen.loland@oracle.com>
branch nick: mysql-trunk-11765831
timestamp: Thu 2011-05-19 14:03:55 +0200
message:
BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
AWAY QUALIFYING ROWS
The problem was that the ranges created when OR'ing two
conditions could be incorrect. Without the bugfix,
"I <> 6 OR (I <> 8 AND J = 5)" would create these ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8 AND 5 <= J <= 5",
"8 < I"
While the correct ranges is
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
The problem occurs when key_or() ORs
(1) "NULL < I < 6, 6 <= I <= 6 AND 5 <= J <= 5, 6 < I" with
(2) "8 < I AND 5 <= J <= 5"
The reason for the bug is that in key_or(), SEL_ARG *tmp is
used to point to the range in (1) above that is merged with
(2) while key1 points to the root of the red-black tree of
(1). When merging (1) and (2), tmp refers to the "6 < I"
part whereas the root is the "6 <= ... AND 5 <= J <= 5" part.
key_or() decides that the tmp range needs to be split into
"6 < I < 8, 8 <= I <= 8, 8 < I", in which next_key_part of the
second range should be that of tmp. However, next_key_part is
set to key1->next_key_part ("5 <= J <= 5") instead of
tmp->next_key_part (empty). Fixing this gives the correct but
not optimal ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8",
"8 < I"
A second problem can be seen above: key_or() may create
adjacent ranges that could be replaced with a single range.
Fixes for this is also included in the patch so that the range
above becomes correct AND optimal:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
Merging adjacent ranges like this gives a slightly lower cost
estimate for the range access.
15 years ago  Backport of:
revno: 2876.47.174
revision-id: jorgen.loland@oracle.com-20110519120355-qn7eprkad9jqwu5j
parent: mayank.prasad@oracle.com-20110518143645-bdxv4udzrmqsjmhq
committer: Jorgen Loland <jorgen.loland@oracle.com>
branch nick: mysql-trunk-11765831
timestamp: Thu 2011-05-19 14:03:55 +0200
message:
BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
AWAY QUALIFYING ROWS
The problem was that the ranges created when OR'ing two
conditions could be incorrect. Without the bugfix,
"I <> 6 OR (I <> 8 AND J = 5)" would create these ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8 AND 5 <= J <= 5",
"8 < I"
While the correct ranges is
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
The problem occurs when key_or() ORs
(1) "NULL < I < 6, 6 <= I <= 6 AND 5 <= J <= 5, 6 < I" with
(2) "8 < I AND 5 <= J <= 5"
The reason for the bug is that in key_or(), SEL_ARG *tmp is
used to point to the range in (1) above that is merged with
(2) while key1 points to the root of the red-black tree of
(1). When merging (1) and (2), tmp refers to the "6 < I"
part whereas the root is the "6 <= ... AND 5 <= J <= 5" part.
key_or() decides that the tmp range needs to be split into
"6 < I < 8, 8 <= I <= 8, 8 < I", in which next_key_part of the
second range should be that of tmp. However, next_key_part is
set to key1->next_key_part ("5 <= J <= 5") instead of
tmp->next_key_part (empty). Fixing this gives the correct but
not optimal ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8",
"8 < I"
A second problem can be seen above: key_or() may create
adjacent ranges that could be replaced with a single range.
Fixes for this is also included in the patch so that the range
above becomes correct AND optimal:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
Merging adjacent ranges like this gives a slightly lower cost
estimate for the range access.
15 years ago  Backport of:
revno: 2876.47.174
revision-id: jorgen.loland@oracle.com-20110519120355-qn7eprkad9jqwu5j
parent: mayank.prasad@oracle.com-20110518143645-bdxv4udzrmqsjmhq
committer: Jorgen Loland <jorgen.loland@oracle.com>
branch nick: mysql-trunk-11765831
timestamp: Thu 2011-05-19 14:03:55 +0200
message:
BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
AWAY QUALIFYING ROWS
The problem was that the ranges created when OR'ing two
conditions could be incorrect. Without the bugfix,
"I <> 6 OR (I <> 8 AND J = 5)" would create these ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8 AND 5 <= J <= 5",
"8 < I"
While the correct ranges is
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
The problem occurs when key_or() ORs
(1) "NULL < I < 6, 6 <= I <= 6 AND 5 <= J <= 5, 6 < I" with
(2) "8 < I AND 5 <= J <= 5"
The reason for the bug is that in key_or(), SEL_ARG *tmp is
used to point to the range in (1) above that is merged with
(2) while key1 points to the root of the red-black tree of
(1). When merging (1) and (2), tmp refers to the "6 < I"
part whereas the root is the "6 <= ... AND 5 <= J <= 5" part.
key_or() decides that the tmp range needs to be split into
"6 < I < 8, 8 <= I <= 8, 8 < I", in which next_key_part of the
second range should be that of tmp. However, next_key_part is
set to key1->next_key_part ("5 <= J <= 5") instead of
tmp->next_key_part (empty). Fixing this gives the correct but
not optimal ranges:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I < 8",
"8 <= I <= 8",
"8 < I"
A second problem can be seen above: key_or() may create
adjacent ranges that could be replaced with a single range.
Fixes for this is also included in the patch so that the range
above becomes correct AND optimal:
"NULL < I < 6",
"6 <= I <= 6 AND 5 <= J <= 5",
"6 < I"
Merging adjacent ranges like this gives a slightly lower cost
estimate for the range access.
15 years ago  BUG#18068: SELECT DISTINCT (with duplicates and covering index)
When converting DISTINCT to GROUP BY where the columns are from the covering
index and they are quoted twice in the SELECT list the optimizer is creating
improper processing sequence. This is because of the fact that the columns
of the covering index are not recognized as such and treated as non-index
columns.
Generally speaking duplicate columns can safely be removed from the GROUP
BY/DISTINCT list because this will not add or remove new rows in the
resulting set. Duplicates can be removed even if they are not consecutive
(as is the case for ORDER BY, where the duplicate columns can be removed
only if they are consecutive).
So we can safely transform "SELECT DISTINCT a,a FROM ... ORDER BY a" to
"SELECT a,a FROM ... GROUP BY a ORDER BY a" instead of
"SELECT a,a FROM .. GROUP BY a,a ORDER BY a". We can even transform
"SELECT DISTINCT a,b,a FROM ... ORDER BY a,b" to
"SELECT a,b,a FROM ... GROUP BY a,b ORDER BY a,b".
The fix to this bug consists of checking for duplicate columns in the SELECT
list when constructing the GROUP BY list in transforming DISTINCT to GROUP
BY and skipping the ones that are already in.
mysql-test/r/distinct.result:
test case for the bug without loose index scan
mysql-test/r/group_min_max.result:
test case for the bug
mysql-test/t/distinct.test:
test case for the bug without loose index scan
mysql-test/t/group_min_max.test:
test case for the bug
sql/sql_select.cc:
duplicates check and removal
20 years ago |
|
drop table if exists t1;create table t1 (a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ');insert into t1 (a1, a2, b, c, d) values('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');create index idx_t1_0 on t1 (a1);create index idx_t1_1 on t1 (a1,a2,b,c);create index idx_t1_2 on t1 (a1,a2,b);analyze table t1;Table Op Msg_type Msg_texttest.t1 analyze status Table is already up to datedrop table if exists t2;create table t2 (a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(64) default ' ');insert into t2 select * from t1;insert into t2 (a1, a2, b, c, d) values('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),('a','a','a',NULL,'xyz'),('a','a','b',NULL,'xyz'),('a','b','a',NULL,'xyz'),('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),('d','b','b',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),('a','a','a',NULL,'xyz'),('a','a','b',NULL,'xyz'),('a','b','a',NULL,'xyz'),('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),('d','b','b',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz');create index idx_t2_0 on t2 (a1);create index idx_t2_1 on t2 (a1,a2,b,c);create index idx_t2_2 on t2 (a1,a2,b);analyze table t2;Table Op Msg_type Msg_texttest.t2 analyze status Table is already up to datedrop table if exists t3;create table t3 (a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' ');insert into t3 (a1, a2, b, c, d) values('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');insert into t3 (a1, a2, b, c, d) values('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');insert into t3 (a1, a2, b, c, d) values('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');insert into t3 (a1, a2, b, c, d) values('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');create index idx_t3_0 on t3 (a1);create index idx_t3_1 on t3 (a1,a2,b,c);create index idx_t3_2 on t3 (a1,a2,b);analyze table t3;Table Op Msg_type Msg_texttest.t3 analyze status Table is already up to dateexplain select a1, min(a2) from t1 group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-byexplain select a1, max(a2) from t1 group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-byexplain select a1, min(a2), max(a2) from t1 group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-byexplain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byexplain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byexplain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-byexplain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-byexplain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byexplain select min(a2) from t1 group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-byexplain select a2, min(c), max(c) from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byselect a1, min(a2) from t1 group by a1;a1 min(a2)a ab ac ad aselect a1, max(a2) from t1 group by a1;a1 max(a2)a bb bc bd bselect a1, min(a2), max(a2) from t1 group by a1;a1 min(a2) max(a2)a a bb a bc a bd a bselect a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;a1 a2 b max(c) min(c)a a a d111 a111a a b h112 e112a b a l121 i121a b b p122 m122b a a d211 a211b a b h212 e212b b a l221 i221b b b p222 m222c a a d311 a311c a b h312 e312c b a l321 i321c b b p322 m322d a a d411 a411d a b h412 e412d b a l421 i421d b b p422 m422select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;a1 a2 b max(c) min(c)a a NULL a999 a777a a a d111 a111a a b h112 e112a b a l121 i121a b b p122 m122b a a d211 a211b a b h212 e212b b a l221 i221b b b p222 m222c a NULL c999 c777c a a d311 a311c a b h312 e312c b a l321 i321c b b p322 m322d a a d411 a411d a b h412 e412d b a l421 i421d b b p422 m422e a a NULL NULLe a b NULL NULLselect min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;min(a2) a1 max(a2) min(a2) a1a a b a aa b b a ba c b a ca d b a dselect a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;a1 b min(c) a1 max(c) b a2 max(c) max(c)a a a111 a d111 a a d111 d111a b e112 a h112 b a h112 h112a a i121 a l121 a b l121 l121a b m122 a p122 b b p122 p122b a a211 b d211 a a d211 d211b b e212 b h212 b a h212 h212b a i221 b l221 a b l221 l221b b m222 b p222 b b p222 p222c a a311 c d311 a a d311 d311c b e312 c h312 b a h312 h312c a i321 c l321 a b l321 l321c b m322 c p322 b b p322 p322d a a411 d d411 a a d411 d411d b e412 d h412 b a h412 h412d a i421 d l421 a b l421 l421d b m422 d p422 b b p422 p422select min(a2) from t1 group by a1;min(a2)aaaaselect a2, min(c), max(c) from t1 group by a1,a2,b;a2 min(c) max(c)a a111 d111a e112 h112b i121 l121b m122 p122a a211 d211a e212 h212b i221 l221b m222 p222a a311 d311a e312 h312b i321 l321b m322 p322a a411 d411a e412 h412b i421 l421b m422 p422explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byselect a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;a1 a2 b min(c) max(c)b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;a1 max(c)a d111a h112a l121a p122c d311c h312c l321c p322d d411d h412d l421d p422select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112b a a a211 d211b a b e212 h212c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;a1 a2 b max(c)b a a d211b a b h212b b a l221b b b p222d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;a1 a2 b min(c) max(c)b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select 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;a1 a2 b max(c)a b a l121a b b p122b b a l221b b b p222c b a l321c b b p322d b a l421d b b p422select 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;a1 a2 b min(c) max(c)a b a i121 l121a b b m122 p122b b a i221 l221b b b m222 p222c b a i321 l321c b b m322 p322d b a i421 l421d b b m422 p422select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;a1 min(c) max(c)b a211 d211b e212 h212b i221 l221b m222 p222c a311 d311c e312 h312c i321 l321c m322 p322d a411 d411d e412 h412d i421 l421d m422 p422select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;a1 max(c)a d111a h112a l121a p122b d211b h212b l221b p222d d411d h412d l421d p422select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;a1 a2 b max(c)a a NULL a999a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a NULL c999c a a d311c a b h312c b a l321c b b p322select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;a1 a2 b min(c) max(c)a a NULL a777 a999a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a NULL c777 c999c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;a1 a2 b min(c) max(c)b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a NULL c777 c999c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422e a a NULL NULLe a b NULL NULLselect a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;a1 a2 b max(c)a a NULL a999a a a d111a a b h112a b a l121a b b p122c a NULL c999c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422e a a NULLe a b NULLselect a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;a1 max(c)a a999a d111a h112a l121a p122c c999c d311c h312c l321c p322d d411d h412d l421d p422e NULLe NULLselect a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;a1 a2 b min(c) max(c)a a NULL a777 a999a a a a111 d111a a b e112 h112b a a a211 d211b a b e212 h212c a NULL c777 c999c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422e a a NULL NULLe a b NULL NULLselect a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;a1 a2 b max(c)b a a d211b a b h212b b a l221b b b p222d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;a1 a2 b min(c) max(c)b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select 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;a1 a2 b max(c)a b a l121a b b p122b b a l221b b b p222c b a l321c b b p322d b a l421d b b p422select 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;a1 a2 b min(c) max(c)a b a i121 l121a b b m122 p122b b a i221 l221b b b m222 p222c b a i321 l321c b b m322 p322d b a i421 l421d b b m422 p422select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;a1 min(c) max(c)b a211 d211b e212 h212b i221 l221b m222 p222c c777 c999c a311 d311c e312 h312c i321 l321c m322 p322d a411 d411d e412 h412d i421 l421d m422 p422e NULL NULLe NULL NULLselect a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;a1 max(c)a a999a d111a h112a l121a p122b d211b h212b l221b p222d d411d h412d l421d p422explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-byexplain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-byexplain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-byexplain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-byexplain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-byexplain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-byexplain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-byselect a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;a1 a2 b max(c) min(c)a a b h112 e112b a b h212 e212c a b h312 e312d a b h412 e412select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;a1 max(c) min(c)a h112 e112b h212 e212c h312 e312d h412 e412select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;a1 a2 b max(c)a a b h112a b b p122b a b h212b b b p222c a b h312c b b p322d a b h412d b b p422select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;a1 a2 b min(c) max(c)a a b e112 h112a b b m122 p122b a b e212 h212b b b m222 p222c a b e312 h312c b b m322 p322d a b e412 h412d b b m422 p422select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;a1 a2 max(c)a a h112a b p122b a h212b b p222c a h312c b p322d a h412d b p422select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;a1 a2 b max(c) min(c)a a b h112 e112b a b h212 e212c a b h312 e312d a b h412 e412e a b NULL NULLselect a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;a1 max(c) min(c)a h112 e112b h212 e212c h312 e312d h412 e412e NULL NULLselect a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;a1 a2 b max(c)a a b h112a b b p122b a b h212b b b p222c a b h312c b b p322d a b h412d b b p422e a b NULLselect a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;a1 a2 b min(c) max(c)a a b e112 h112a b b m122 p122b a b e212 h212b b b m222 p222c a b e312 h312c b b m322 p322d a b e412 h412d b b m422 p422e a b NULL NULLselect a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;a1 a2 max(c)a a h112a b p122b a h212b b p222c a h312c b p322d a h412d b p422e a NULLselect a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;a1 a2 b max(c) min(c)a a b h112 e112b a b h212 e212c a b h312 e312select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;a1 max(c) min(c)a h112 e112b h212 e212c h312 e312explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 5 Using where; Using index for group-byexplain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL 5 Using where; Using index for group-byexplain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-byselect a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;a1 a2 b min(c)a a NULL a777c a NULL c777select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;a1 a2 b max(c)a a NULL a999c a NULL c999select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;a1 a2 b min(c)a a NULL a777c a NULL c777select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;a1 a2 b max(c)a a NULL a999c a NULL c999select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;a1 a2 b min(c) max(c)a a NULL a777 a999c a NULL c777 c999select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;a1 a2 b min(c) max(c)a a NULL a777 a999c a NULL c777 c999explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byselect a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;a1 a2 b min(c) max(c)a a a b111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a b211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;a1 a2 b max(c)a a b h112a b a l121a b b p122b a b h212b b a l221b b b p222c a b h312c b a l321c b b p322d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;a1 a2 b min(c) max(c)a a b g112 h112a b a i121 l121a b b m122 p122b a b f212 h212b b a i221 l221b b b m222 p222c a b f312 h312c b a i321 l321c b b m322 p322d a b f412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;a1 a2 b max(c)select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;a1 a2 b min(c) max(c)select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a k121b a a d211b a b h212b b a k221c a a d311c a b h312c b a j321d a a d411d a b h412d b a j421select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 k121b a a a211 d211b a b e212 h212b b a i221 k221c a a a311 d311c a b e312 h312c b a i321 j321d a a a411 d411d a b e412 h412d b a i421 j421select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;a1 a2 b min(c) max(c)a a a b111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a b211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 g112b a a b211 d211b a b e212 f212c a a b311 d311c a b e312 f312d a a b411 d411d a b e412 f412select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 c111b a a a211 c211c a a a311 c311d a a a411 c411d a b g412 g412d b a k421 k421select 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;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 h112b a a b211 d211b a b e212 h212c a a b311 d311c a b e312 h312d a a b411 d411d a b e412 h412select 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;a1 a2 b min(c) max(c)a a a b111 d111a a b e112 h112b a a b211 d211b a b e212 h212c a a b311 d311c a b e312 h312d a a b411 d411d a b e412 h412select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a NULL c999c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;a1 a2 b min(c) max(c)a a a b111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a b211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a NULL c777 c999c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;a1 a2 b max(c)a a b h112a b a l121a b b p122b a b h212b b a l221b b b p222c a b h312c b a l321c b b p322d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;a1 a2 b min(c) max(c)a a b g112 h112a b a i121 l121a b b m122 p122b a b f212 h212b b a i221 l221b b b m222 p222c a b f312 h312c b a i321 l321c b b m322 p322d a b f412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;a1 a2 b max(c)select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;a1 a2 b min(c) max(c)select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;a1 a2 b max(c)a a NULL a999a a a d111a a b h112a b a k121b a a d211b a b h212b b a k221c a NULL c999c a a d311c a b h312c b a j321d a a d411d a b h412d b a j421select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;a1 a2 b min(c) max(c)a a NULL a777 a999a a a a111 d111a a b e112 h112a b a i121 k121b a a a211 d211b a b e212 h212b b a i221 k221c a NULL c777 c999c a a a311 d311c a b e312 h312c b a i321 j321d a a a411 d411d a b e412 h412d b a i421 j421select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;a1 a2 b max(c)a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a NULL c999c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;a1 a2 b min(c) max(c)a a a b111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a b211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a NULL c777 c999c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;a1 a2 b max(c)a a NULL a999a a a d111a a b h112a b a l121a b b p122b a a d211b a b h212b b a l221b b b p222c a NULL c999c a a d311c a b h312c b a l321c b b p322d a a d411d a b h412d b a l421d b b p422select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;a1 a2 b min(c) max(c)a a NULL a777 a999a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a NULL c777 c999c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 g112b a a b211 d211b a b e212 f212c a NULL c777 c999c a a b311 d311c a b e312 f312d a a b411 d411d a b e412 f412select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;a1 a2 b min(c) max(c)a a NULL a777 a999a a a a111 c111b a a a211 c211c a a a311 c311d a a a411 c411d a b g412 g412d b a k421 k421select 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;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 h112b a a b211 d211b a b e212 h212c a NULL c777 c999c a a b311 d311c a b e312 h312d a a b411 d411d a b e412 h412explain select a1,a2,b,min(c),max(c) from t1where exists ( select * from t2 where t2.c = t1.c )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexselect a1,a2,b,min(c),max(c) from t1where exists ( select * from t2 where t2.c = t1.c )group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422explain select a1,a2,b,min(c),max(c) from t1where exists ( select * from t2 where t2.c > 'b1' )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexselect a1,a2,b,min(c),max(c) from t1where exists ( select * from t2 where t2.c > 'b1' )group by a1,a2,b;a1 a2 b min(c) max(c)a a a a111 d111a a b e112 h112a b a i121 l121a b b m122 p122b a a a211 d211b a b e212 h212b b a i221 l221b b b m222 p222c a a a311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a a411 d411d a b e412 h412d b a i421 l421d b b m422 p422explain select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexselect a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )group by a1,a2,b;a1 a2 b c min(c) max(c)a a b h112 e112 h112a b b p122 m122 p122b a b h212 e212 h212b b b p222 m222 p222c a b h312 e312 h312c b b p322 m322 p322d a b h412 e412 h412d b b p422 m422 p422SET @save_optimizer_switch=@@optimizer_switch;SET optimizer_switch='semijoin_with_cache=off';explain select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2where t2.c in (select c from t3 where t3.c > t1.b) andt2.c > 'b1' )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2where t2.c in (select c from t3 where t3.c > t1.b) andt2.c > 'b1' )group by a1,a2,b;a1 a2 b c min(c) max(c)a a a d111 a111 d111a a b h112 e112 h112a b a l121 i121 l121a b b p122 m122 p122b a a d211 a211 d211b a b h212 e212 h212b b a l221 i221 l221b b b p222 m222 p222c a a d311 a311 d311c a b h312 e312 h312c b a l321 i321 l321c b b p322 m322 p322d a a d411 a411 d411d a b h412 e412 h412d b a l421 i421 l421d b b p422 m422 p422SET optimizer_switch=@save_optimizer_switch;explain select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexselect a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )group by a1,a2,b;a1 a2 b c min(c) max(c)a a a a111 a111 d111a a b e112 e112 h112a b a i121 i121 l121a b b m122 m122 p122b a a a211 a211 d211b a b e212 e212 h212b b a i221 i221 l221b b b m222 m222 p222c a a a311 a311 d311c a b e312 e312 h312c b a i321 i321 l321c b b m322 m322 p322d a a a411 a411 d411d a b e412 e412 h412d b a i421 i421 l421d b b m422 m422 p422SET @save_optimizer_switch=@@optimizer_switch;SET optimizer_switch='semijoin_with_cache=off';explain select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2where t2.c in (select c from t3 where t3.c > t1.c) andt2.c > 'b1' )group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)select a1,a2,b,c,min(c), max(c) from t1where exists ( select * from t2where t2.c in (select c from t3 where t3.c > t1.c) andt2.c > 'b1' )group by a1,a2,b;a1 a2 b c min(c) max(c)a a a a111 a111 d111a a b e112 e112 h112a b a i121 i121 l121a b b m122 m122 p122b a a a211 a211 d211b a b e212 e212 h212b b a i221 i221 l221b b b m222 m222 p222c a a a311 a311 d311c a b e312 e312 h312c b a i321 i321 l321c b b m322 m322 o322d a a a411 a411 d411d a b e412 e412 h412d b a i421 i421 l421d b b m422 m422 o422SET optimizer_switch=@save_optimizer_switch;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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-byexplain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain 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;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byexplain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-byselect a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;a1 a2 b min(c) max(c)a a b e112 h112b a b e212 h212c a b e312 h312c b b m322 p322d a b e412 h412d b b m422 p422select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 h112b a a b211 d211b a b e212 h212c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;a1 a2 b min(c) max(c)a b a i121 l121b b a i221 l221c b a i321 l321d b a i421 l421select 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;a1 a2 b min(c)b b a k221c b a k321d b a k421select 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;a1 a2 b min(c)b b a k221c b a k321d b a k421select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 b min(c)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;a1 a2 b min(c)select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;a1 a2 b min(c) max(c)a a b e112 h112b a b e212 h212c a b e312 h312c b b m322 p322d a b e412 h412d b b m422 p422e a b NULL NULLselect a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;a1 a2 b min(c) max(c)a a a c111 d111a a b e112 h112b a a b211 d211b a b e212 h212c a NULL c777 c999c a a b311 d311c a b e312 h312c b a i321 l321c b b m322 p322d a a b411 d411d a b e412 h412d b a i421 l421d b b m422 p422select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;a1 a2 b min(c) max(c)a b a i121 l121b b a i221 l221c b a i321 l321d b a i421 l421select 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;a1 a2 b min(c)b b a k221c b a k321d b a k421select 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;a1 a2 b min(c)b b a k221c b a k321d b a k421select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 b min(c)explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL # Using where; Using indexexplain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byselect a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;a1 a2 ba a bb a bc a bc b bd a bd b bselect a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;a1 a2 ba b ab b ac b ad b aselect a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;a1 a2 b ca b a i121select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 bselect a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;a1 a2 ba a bb a bc a bc b bd a bd b be a bselect a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;a1 a2 ba b ab b ac b ad b aselect a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;a1 a2 b ca b a i121select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 bexplain select distinct a1,a2,b from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byexplain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 50.78 Using where; Using indexWarnings: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'))explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select distinct b from t1 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using indexexplain select distinct a1,a2,b from t2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-byexplain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 50.61 Using where; Using indexWarnings: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'))explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select distinct b from t2 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using indexselect distinct a1,a2,b from t1;a1 a2 ba a aa a ba b aa b bb a ab a bb b ab b bc a ac a bc b ac b bd a ad a bd b ad b bselect distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');a1 a2 ba b ab b ac b ad b aselect distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');a1 a2 b ca b a i121select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');a1 a2 bselect distinct b from t1 where (a2 >= 'b') and (b = 'a');baselect distinct a1,a2,b from t2;a1 a2 ba a NULLa a aa a ba b aa b bb a ab a bb b ab b bc a NULLc a ac a bc b ac b bd a ad a bd b ad b be a ae a bselect distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');a1 a2 ba b ab b ac b ad b aselect distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');a1 a2 b ca b a i121select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');a1 a2 bselect distinct b from t2 where (a2 >= 'b') and (b = 'a');baselect distinct t_00.a1from t1 t_00where exists ( select * from t2 where a1 = t_00.a1 );a1abcdselect distinct a1,a1 from t1;a1 a1a ab bc cd dselect distinct a2,a1,a2,a1 from t1;a2 a1 a2 a1a a a ab a b aa b a bb b b ba c a cb c b ca d a db d b dselect distinct t1.a1,t2.a1 from t1,t2;a1 a1a ab ac ad aa bb bc bd ba cb cc cd ca db dc dd da eb ec ed eexplain select distinct a1,a2,b from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-byexplain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-byexplain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-byexplain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-byexplain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesortexplain select distinct a1,a2,b from t2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-byexplain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-byexplain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL # Using where; Using indexexplain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-byexplain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by; Using temporary; Using filesortselect distinct a1,a2,b from t1;a1 a2 ba a aa a ba b aa b bb a ab a bb b ab b bc a ac a bc b ac b bd a ad a bd b ad b bselect distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;a1 a2 ba b ab b ac b ad b aselect distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;a1 a2 b ca b a i121select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 bselect distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;baselect distinct a1,a2,b from t2;a1 a2 ba a NULLa a aa a ba b aa b bb a ab a bb b ab b bc a NULLc a ac a bc b ac b bd a ad a bd b ad b be a ae a bselect distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;a1 a2 ba b ab b ac b ad b aselect distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;a1 a2 b ca b a i121select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;a1 a2 bselect distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;baexplain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using indexexplain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using indexexplain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using indexWarnings: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'))explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using indexexplain extended select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using indexWarnings: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'))select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');count(distinct a1,a2,b)4select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');count(distinct a1,a2,b,c)1select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');count(distinct a1,a2,b)0select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');count(distinct b)1select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');ord(a1) + count(distinct a1,a2,b)104explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-byexplain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-byselect a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;a1 a2 b concat(min(c), max(c))a a a a111d111a a b e112h112a b a i121l121a b b m122p122b a a a211d211b a b e212h212b b a i221l221b b b m222p222c a a a311d311c a b e312h312c b a i321l321c b b m322p322select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;concat(a1,min(c)) baa111 aae112 bai121 aam122 bba211 abe212 bbi221 abm222 bca311 ace312 bci321 acm322 bselect concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;concat(a1,min(c)) b max(c)aa111 a d111ae112 b h112ai121 a l121am122 b p122ba211 a d211be212 b h212bi221 a l221bm222 b p222ca311 a d311ce312 b h312ci321 a l321cm322 b p322select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;concat(a1,a2) b min(c) max(c)aa a a111 d111aa b e112 h112ab a i121 l121ab b m122 p122ba a a211 d211ba b e212 h212bb a i221 l221bb b m222 p222ca a a311 d311ca b e312 h312cb a i321 l321cb b m322 p322select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;concat(ord(min(b)),ord(max(b))) min(b) max(b)9798 a b9798 a b9798 a b9798 a b9798 a b9798 a b9798 a b9798 a bexplain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesortexplain select a1,a2,b,d from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesortexplain extended select a1,a2,min(b),max(b) from t1where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using indexWarnings: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`explain extended select a1,a2,b,min(c),max(c) from t1where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesortWarnings: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`explain extended select a1,a2,b,c from t1where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesortWarnings: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`explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexexplain 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;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 85.53 Using where; Using indexWarnings: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`explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexselect a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;a1 a2 min(b) ca a a a111explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexexplain select a1,a2,b,min(c),max(c) from t2where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using indexexplain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesortexplain select a1,a2,count(a2) from t1 group by a1,a2,b;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using indexexplain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using indexWarnings: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`explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using indexWarnings: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`explain select distinct(a1) from t1 where ord(a2) = 98;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using indexselect distinct(a1) from t1 where ord(a2) = 98;a1abcdexplain select a1 from t1 where a2 = 'b' group by a1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-byselect a1 from t1 where a2 = 'b' group by a1;a1abcdexplain select distinct a1 from t1 where a2 = 'b';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-byselect distinct a1 from t1 where a2 = 'b';a1abcddrop table t1,t2,t3;create table t1 (c1 int not null,c2 int not null, primary key(c1,c2));insert into t1 (c1,c2) values(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9);select distinct c1, c2 from t1 order by c2;c1 c210 110 210 320 420 520 630 730 830 9select c1,min(c2) as c2 from t1 group by c1 order by c2;c1 c210 120 430 7select c1,c2 from t1 group by c1,c2 order by c2;c1 c210 110 210 320 420 520 630 730 830 9drop table t1;CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b));INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4);OPTIMIZE TABLE t1;Table Op Msg_type Msg_texttest.t1 optimize status OKSELECT a FROM t1 WHERE a='AA' GROUP BY a;aAASELECT a FROM t1 WHERE a='BB' GROUP BY a;aBBEXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 3 Using where; Using indexEXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using indexSELECT DISTINCT a FROM t1 WHERE a='BB';aBBSELECT DISTINCT a FROM t1 WHERE a LIKE 'B%';aBBSELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a;aBBDROP TABLE t1;CREATE TABLE t1 (a int(11) NOT NULL DEFAULT '0',b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '',PRIMARY KEY (a,b)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;CREATE PROCEDURE a(x INT)BEGINDECLARE rnd INT;DECLARE cnt INT;WHILE x > 0 DOSET rnd= x % 100;SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd);INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR));SET x= x - 1;END WHILE;END|CALL a(1000);SELECT a FROM t1 WHERE a=0;a0000000000SELECT DISTINCT a FROM t1 WHERE a=0;a0SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0;COUNT(DISTINCT a)1DROP TABLE t1;DROP PROCEDURE a;CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a));INSERT INTO t1 (a) VALUES (''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL PRIMARY 66 NULL 12 Using index for group-bySELECT DISTINCT a,a FROM t1 ORDER BY a;a a CENTRAL CENTRALEASTERN EASTERNGREATER LONDON GREATER LONDONNORTH CENTRAL NORTH CENTRALNORTH EAST NORTH EASTNORTH WEST NORTH WESTSCOTLAND SCOTLANDSOUTH EAST SOUTH EASTSOUTH WEST SOUTH WESTWESTERN WESTERNDROP TABLE t1;CREATE TABLE t1 (id1 INT, id2 INT);CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);CREATE TABLE t3 (id3 INT, id4 INT);CREATE TABLE t4 (id4 INT);CREATE TABLE t5 (id5 INT, id6 INT);CREATE TABLE t6 (id6 INT);INSERT INTO t1 VALUES(1,1);INSERT INTO t2 VALUES(1,1,1);INSERT INTO t3 VALUES(1,1);INSERT INTO t4 VALUES(1);INSERT INTO t5 VALUES(1,1);INSERT INTO t6 VALUES(1);SELECT * FROMt1NATURAL JOIN(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));id2 id1 id3 id5 id4 id3 id6 id51 1 1 1 1 1 1 1SELECT * FROMt1NATURAL JOIN(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));id2 id1 id4 id3 id6 id5 id3 id51 1 1 1 1 1 1 1SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);id2 id1 id3 id4 id6 id5 id3 id51 1 1 1 1 1 1 1SELECT * FROM(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))NATURAL JOINt1;id2 id3 id5 id4 id3 id6 id5 id11 1 1 1 1 1 1 1SELECT * FROM(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))NATURAL JOINt1;id2 id3 id5 id4 id3 id6 id5 id11 1 1 1 1 1 1 1DROP TABLE t1,t2,t3,t4,t5,t6;CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b));INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 1 Using where; Using index for group-bySELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;MAX(b) a1 1SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a;MIN(b) a2 1CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));INSERT INTO t2 SELECT a,b,b FROM t1;explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index for group-bySELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;MIN(c)2DROP TABLE t1,t2;CREATE TABLE t1 (a INT, b INT, INDEX (a,b));INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-byFLUSH STATUS;SELECT max(b), a FROM t1 GROUP BY a;max(b) a5 13 21 36 4SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-byFLUSH STATUS;CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0FLUSH STATUS;SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;max(b) a5 13 21 36 4SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0FLUSH STATUS;(SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a);max(b) a5 13 21 36 4SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 16Handler_read_next 0EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 range NULL a 5 NULL 8 Using index for group-by2 UNION t1 range NULL a 5 NULL 8 Using index for group-byNULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) xFROM t1 AS t1_outer;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-byEXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index2 SUBQUERY t1 index NULL a 10 NULL 1 Using indexEXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-byEXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 Using index2 MATERIALIZED t1 range NULL a 5 NULL 8 Using index for group-byEXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer range NULL a 5 NULL 8 Using index for group-by2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-byEXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) AND t1_outer1.b = t1_outer2.b;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer1 ref a a 5 const 2 Using where; Using index1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-byEXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) xFROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index3 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-byCREATE TABLE t3 LIKE t1;FLUSH STATUS;INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0DELETE FROM t3;FLUSH STATUS;INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) FROM t1 LIMIT 1;SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0FLUSH STATUS;DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;SHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 0FLUSH STATUS;DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1) > 10000;ERROR 21000: Subquery returns more than 1 rowSHOW STATUS LIKE 'handler_read__e%';Variable_name ValueHandler_read_key 8Handler_read_next 1DROP TABLE t1,t2,t3;CREATE TABLE t1 (a int, INDEX idx(a));INSERT INTO t1 VALUES(4), (2), (1), (2), (4), (2), (1), (4),(4), (2), (1), (2), (2), (4), (1), (4);EXPLAIN SELECT DISTINCT(a) FROM t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-bySELECT DISTINCT(a) FROM t1;a124EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-bySELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;a124DROP TABLE t1;CREATE TABLE t1 (a INT, b INT);INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);INSERT INTO t1 SELECT a + 1, b FROM t1;INSERT INTO t1 SELECT a + 2, b FROM t1;EXPLAINSELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesortSELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;a MIN(b) MAX(b)4 1 33 1 32 1 31 1 3CREATE INDEX break_it ON t1 (a, b);EXPLAINSELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-bySELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;a MIN(b) MAX(b)1 1 32 1 33 1 34 1 3EXPLAINSELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by; Using temporary; Using filesortSELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;a MIN(b) MAX(b)4 1 33 1 32 1 31 1 3EXPLAINSELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL break_it 10 NULL 12 Using indexSELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;a MIN(b) MAX(b) AVG(b)4 1 3 2.00003 1 3 2.00002 1 3 2.00001 1 3 2.0000DROP TABLE t1;create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;insert into t1 (a,b) values (0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;select * from t1;a b0 00 10 20 30 40 50 60 70 80 90 100 110 120 130 141 01 11 21 31 41 51 61 71 81 91 101 111 121 132 02 12 22 32 42 52 62 72 82 92 102 112 122 133 03 13 23 33 43 53 63 73 83 93 103 113 123 13explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 ref PRIMARY,index PRIMARY 4 const 15 100.00 Using index; Using temporaryWarnings: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`drop table t1;CREATE TABLE t1 (a int, b int, c int, d int,KEY foo (c,d,a,b), KEY bar (c,a,b,d));INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);INSERT INTO t1 SELECT * FROM t1;INSERT INTO t1 SELECT * FROM t1;INSERT INTO t1 SELECT a,b,c+1,d FROM t1;EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range NULL foo 10 NULL 9 Using where; Using index for group-bySELECT DISTINCT c FROM t1 WHERE d=4;c12DROP TABLE t1;## Bug #45386: Wrong query result with MIN function in field list, # WHERE and GROUP BY clause#CREATE TABLE t (a INT, b INT, INDEX (a,b));INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);INSERT INTO t SELECT * FROM t;# test MIN#should use range with index for group byEXPLAINSELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by#should return 1 rowSELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;a MIN(b)2 1# test MAX#should use range with index for group byEXPLAINSELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by#should return 1 rowSELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;a MAX(b)2 0# test 3 ranges and use the middle oneINSERT INTO t SELECT a, 2 FROM t;#should use range with index for group byEXPLAINSELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by#should return 1 rowSELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;a MAX(b)2 1DROP TABLE t;## Bug #48472: Loose index scan inappropriately chosen for some WHERE# conditions# CREATE TABLE t (a INT, b INT, INDEX (a,b));INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);INSERT INTO t SELECT * FROM t;SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a;a MAX(b)2 0DROP TABLE t;End of 5.0 tests## Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in# server crash#CREATE TABLE t (a INT, b INT, INDEX (a,b));INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);INSERT INTO t SELECT * FROM t;SELECT a, MAX(b) FROM t WHERE b GROUP BY a;a MAX(b)2 1DROP TABLE t;CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b));INSERT INTO t1 VALUES(1,1),(2,1);ANALYZE TABLE t1;Table Op Msg_type Msg_texttest.t1 analyze status OKSELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;c b1 1SELECT a FROM t1 WHERE b=1;a12DROP TABLE t1;# # Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column# for NULL### Test for NULLs allowedCREATE TABLE t1 ( a INT, KEY (a) );INSERT INTO t1 VALUES (1), (2), (3);EXPLAINSELECT MIN( a ) FROM t1 WHERE a = NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a = NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a <> NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a <> NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a > NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a > NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a < NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a < NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a <=> NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x No matching min/max rowSELECT MIN( a ) FROM t1 WHERE a <=> NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Using where; Using indexx x x x x x x x x Using where; Using indexSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a IS NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x No matching min/max rowSELECT MIN( a ) FROM t1 WHERE a IS NULL;MIN( a )NULLINSERT INTO t1 VALUES (NULL), (NULL);EXPLAINSELECT MIN( a ) FROM t1 WHERE a = NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a = NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a <> NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a <> NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a > NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a > NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a < NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a < NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a <=> NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Select tables optimized awaySELECT MIN( a ) FROM t1 WHERE a <=> NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Using where; Using indexx x x x x x x x x Using where; Using indexSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a IS NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Select tables optimized awaySELECT MIN( a ) FROM t1 WHERE a IS NULL;MIN( a )NULLDROP TABLE t1;## Test for NOT NULLsCREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY);INSERT INTO t1 VALUES (1), (2), (3);## NULL-safe operator test disabled for non-NULL indexed columns.## See bugs## - Bug#52173: Reading NULL value from non-NULL index gives# wrong result in embedded server ## - Bug#52174: Sometimes wrong plan when reading a MAX value from # non-NULL index#EXPLAINSELECT MIN( a ) FROM t1 WHERE a = NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a = NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a <> NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a <> NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a > NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a > NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a < NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a < NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERE noticed after reading const tablesSELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Using where; Using indexx x x x x x x x x Using where; Using indexSELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);MIN( a )NULLEXPLAINSELECT MIN( a ) FROM t1 WHERE a IS NULL;id select_type table type possible_keys key key_len ref rows Extrax x x x x x x x x Impossible WHERESELECT MIN( a ) FROM t1 WHERE a IS NULL;MIN( a )NULLDROP TABLE t1;## Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&, Item*) at# opt_sum.cc:305#CREATE TABLE t1 ( a INT, KEY (a) );INSERT INTO t1 VALUES (1), (2), (3);SELECT MIN( a ) AS min_aFROM t1WHERE a > 1 AND a IS NULLORDER BY min_a;min_aNULLDROP TABLE t1;## LP BUG#888456 Wrong result with DISTINCT , ANY , subquery_cache=off , NOT NULL#CREATE TABLE t1 ( a int NOT NULL) ;INSERT INTO t1 VALUES (28),(29),(9);CREATE TABLE t2 ( a int, KEY (a)) ;INSERT INTO t2 VALUES (1),(1),(1),(4),(4),(5),(5),(8),(8),(9);explain select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 ALL NULL NULL NULL NULL 3 2 DEPENDENT SUBQUERY t2 index a a 5 NULL 10 Using where; Using indexselect (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;(select t2.a from t2 where t2.a >= t1.a group by t2.a)NULLNULL9drop table t1, t2;## LP BUG#900375 Wrong result with derived_merge=ON, DISTINCT or GROUP BY, EXISTS#CREATE TABLE t1 ( a INT, b INT, KEY (b) );INSERT INTO t1 VALUES(100,10),(101,11),(102,12),(103,13),(104,14),(105,15),(106,16),(107,17),(108,18),(109,19);EXPLAINSELECT alias1.* FROM t1, (SELECT * FROM t1) AS alias1WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 index NULL b 5 NULL 10 Using index1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)3 DEPENDENT SUBQUERY t1 index b b 5 NULL 10 Using where; Using indexSELECT alias1.* FROM t1, (SELECT * FROM t1) AS alias1WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ;a b100 10100 10100 10100 10100 10100 10100 10100 10100 10100 10101 11101 11101 11101 11101 11101 11101 11101 11101 11101 11102 12102 12102 12102 12102 12102 12102 12102 12102 12102 12103 13103 13103 13103 13103 13103 13103 13103 13103 13103 13104 14104 14104 14104 14104 14104 14104 14104 14104 14104 14105 15105 15105 15105 15105 15105 15105 15105 15105 15105 15106 16106 16106 16106 16106 16106 16106 16106 16106 16106 16107 17107 17107 17107 17107 17107 17107 17107 17107 17107 17108 18108 18108 18108 18108 18108 18108 18108 18108 18108 18109 19109 19109 19109 19109 19109 19109 19109 19109 19109 19EXPLAINSELECT alias1.* FROM t1, t1 AS alias1WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 index NULL b 5 NULL 10 Using index1 PRIMARY alias1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)2 DEPENDENT SUBQUERY t1 index b b 5 NULL 10 Using where; Using indexSELECT alias1.* FROM t1, t1 AS alias1WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ;a b100 10100 10100 10100 10100 10100 10100 10100 10100 10100 10101 11101 11101 11101 11101 11101 11101 11101 11101 11101 11102 12102 12102 12102 12102 12102 12102 12102 12102 12102 12103 13103 13103 13103 13103 13103 13103 13103 13103 13103 13104 14104 14104 14104 14104 14104 14104 14104 14104 14104 14105 15105 15105 15105 15105 15105 15105 15105 15105 15105 15106 16106 16106 16106 16106 16106 16106 16106 16106 16106 16107 17107 17107 17107 17107 17107 17107 17107 17107 17107 17108 18108 18108 18108 18108 18108 18108 18108 18108 18108 18109 19109 19109 19109 19109 19109 19109 19109 19109 19109 19drop table t1;End of 5.1 tests
|