Commit 870acdf5 authored by Marko Mäkelä's avatar Marko Mäkelä

After-merge fix: Re-record results

parent 1d15a28e
connection node_2;
connection node_1;
use performance_schema; use performance_schema;
SELECT name SELECT name
FROM threads FROM threads
...@@ -5,25 +7,29 @@ WHERE name LIKE 'thread/sql/wsrep%' ...@@ -5,25 +7,29 @@ WHERE name LIKE 'thread/sql/wsrep%'
ORDER BY name; ORDER BY name;
name thread/sql/wsrep_applier_thread name thread/sql/wsrep_applier_thread
name thread/sql/wsrep_rollbacker_thread name thread/sql/wsrep_rollbacker_thread
name thread/sql/wsrep_rollbacker_thread
use test; use test;
create table t1 (a int not null primary key) engine=innodb; create table t1 (a int not null primary key) engine=innodb;
insert into t1 values (1),(2); insert into t1 values (1),(2);
use performance_schema; use performance_schema;
select name from mutex_instances where name like 'wait/synch/mutex/sql/LOCK_wsrep%' order by name; select name from mutex_instances where name like 'wait/synch/mutex/sql/LOCK_wsrep%' order by name;
name wait/synch/mutex/sql/LOCK_wsrep_cluster_config
name wait/synch/mutex/sql/LOCK_wsrep_config_state name wait/synch/mutex/sql/LOCK_wsrep_config_state
name wait/synch/mutex/sql/LOCK_wsrep_desync name wait/synch/mutex/sql/LOCK_wsrep_desync
name wait/synch/mutex/sql/LOCK_wsrep_group_commit
name wait/synch/mutex/sql/LOCK_wsrep_ready name wait/synch/mutex/sql/LOCK_wsrep_ready
name wait/synch/mutex/sql/LOCK_wsrep_replaying name wait/synch/mutex/sql/LOCK_wsrep_replaying
name wait/synch/mutex/sql/LOCK_wsrep_rollback
name wait/synch/mutex/sql/LOCK_wsrep_slave_threads name wait/synch/mutex/sql/LOCK_wsrep_slave_threads
name wait/synch/mutex/sql/LOCK_wsrep_SR_pool
name wait/synch/mutex/sql/LOCK_wsrep_SR_store
name wait/synch/mutex/sql/LOCK_wsrep_sst name wait/synch/mutex/sql/LOCK_wsrep_sst
name wait/synch/mutex/sql/LOCK_wsrep_sst_init name wait/synch/mutex/sql/LOCK_wsrep_sst_init
select name from cond_instances where name like 'wait/synch/cond/sql/COND_wsrep%' order by name; select name from cond_instances where name like 'wait/synch/cond/sql/COND_wsrep%' order by name;
name wait/synch/cond/sql/COND_wsrep_ready name wait/synch/cond/sql/COND_wsrep_ready
name wait/synch/cond/sql/COND_wsrep_replaying name wait/synch/cond/sql/COND_wsrep_replaying
name wait/synch/cond/sql/COND_wsrep_rollback
name wait/synch/cond/sql/COND_wsrep_sst name wait/synch/cond/sql/COND_wsrep_sst
name wait/synch/cond/sql/COND_wsrep_sst_init name wait/synch/cond/sql/COND_wsrep_sst_init
name wait/synch/cond/sql/COND_wsrep_wsrep_slave_threads
connection node_2; connection node_2;
use test; use test;
SET SESSION wsrep_on=OFF; SET SESSION wsrep_on=OFF;
......
...@@ -42,6 +42,7 @@ create index idx_t1_1 on t1 (a1,a2,b,c); ...@@ -42,6 +42,7 @@ create index idx_t1_1 on t1 (a1,a2,b,c);
create index idx_t1_2 on t1 (a1,a2,b); create index idx_t1_2 on t1 (a1,a2,b);
analyze table t1; analyze table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
drop table if exists t2; drop table if exists t2;
create table t2 ( create table t2 (
...@@ -70,6 +71,7 @@ create index idx_t2_1 on t2 (a1,a2,b,c); ...@@ -70,6 +71,7 @@ create index idx_t2_1 on t2 (a1,a2,b,c);
create index idx_t2_2 on t2 (a1,a2,b); create index idx_t2_2 on t2 (a1,a2,b);
analyze table t2; analyze table t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK test.t2 analyze status OK
drop table if exists t3; drop table if exists t3;
create table t3 ( create table t3 (
...@@ -132,37 +134,38 @@ create index idx_t3_1 on t3 (a1,a2,b,c); ...@@ -132,37 +134,38 @@ create index idx_t3_1 on t3 (a1,a2,b,c);
create index idx_t3_2 on t3 (a1,a2,b); create index idx_t3_2 on t3 (a1,a2,b);
analyze table t3; analyze table t3;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK test.t3 analyze status OK
explain select a1, min(a2) from t1 group by a1; explain select a1, min(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, max(a2) from t1 group by a1; explain select a1, max(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 63 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
explain select a1, min(a2), max(a2) from t1 group by a1; explain select a1, min(a2), max(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by
explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
explain select min(a2) from t1 group by a1; explain select min(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a2, min(c), max(c) from t1 group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
select a1, min(a2) from t1 group by a1; select a1, min(a2) from t1 group by a1;
a1 min(a2) a1 min(a2)
a a a a
...@@ -289,37 +292,37 @@ b i421 l421 ...@@ -289,37 +292,37 @@ b i421 l421
b m422 p422 b m422 p422
explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 1004 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 1004 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
...@@ -681,97 +684,97 @@ d p422 ...@@ -681,97 +684,97 @@ d p422
# So the following results are not very meaningful, but are still kept here # So the following results are not very meaningful, but are still kept here
explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 63 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1; explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 63 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
explain select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 63 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 63 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
explain select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain select a1,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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
explain select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2; explain select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 range NULL idx_t3_1 6 NULL 63 Using where; Using index for group-by 1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index NULL idx_t3_1 10 NULL 1000 Using where; Using index 1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index NULL idx_t3_1 10 NULL 1000 Using where; Using index 1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 range NULL idx_t3_1 6 NULL 63 Using where; Using index for group-by 1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
explain select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1; explain select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index NULL idx_t3_1 10 NULL 1000 Using where; Using index 1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1; explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index NULL idx_t3_1 10 NULL 1000 Using where; Using index 1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; select 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) a1 a2 b max(c) min(c)
a a b h112 e112 a a b h112 e112
...@@ -1014,25 +1017,25 @@ b h212 a211 ...@@ -1014,25 +1017,25 @@ b h212 a211
c h312 a311 c h312 a311
explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 63 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1; explain select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL 63 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 6 Using where; Using index for group-by
explain select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1; explain select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
a1 a2 b min(c) a1 a2 b min(c)
a a NULL a777 a a NULL a777
...@@ -1070,49 +1073,49 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1070,49 +1073,49 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL # Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL # Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
...@@ -1579,36 +1582,36 @@ explain select a1,a2,b,min(c),max(c) from t1 ...@@ -1579,36 +1582,36 @@ explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c = t1.c ) where exists ( select * from t2 where t2.c = t1.c )
group by a1,a2,b; group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 1000 Using index 1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func 1
2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 1000 Using index 2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 164 Using index
explain select a1,a2,b,min(c),max(c) from t1 explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' ) where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b; group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 1000 Using index 1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
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; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
...@@ -1713,25 +1716,25 @@ select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') grou ...@@ -1713,25 +1716,25 @@ select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') grou
a1 a2 b min(c) 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; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b; explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by
explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
...@@ -1740,7 +1743,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1740,7 +1743,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
a1 a2 b a1 a2 b
a a b a a b
...@@ -1788,50 +1791,50 @@ select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1 ...@@ -1788,50 +1791,50 @@ select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1
a1 a2 b a1 a2 b
explain select distinct a1,a2,b from t1; explain select distinct a1,a2,b from t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using index for group-by
explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); explain 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 501 100.00 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by
Warnings: Warnings:
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`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b' 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`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b'
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by
explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); explain select distinct b from t1 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b'; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e'; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by
explain select distinct a1,a2,b from t2; explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); explain 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL 501 100.00 Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL 83 100.00 Using where; Using index for group-by
Warnings: Warnings:
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`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b' 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`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b'
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
explain select distinct b from t2 where (a2 >= 'b') and (b = 'a'); explain select distinct b from t2 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_2 146 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b'; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 37 Using where; Using index for group-by
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e'; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 37 Using where; Using index for group-by
select distinct a1,a2,b from t1; select distinct a1,a2,b from t1;
a1 a2 b a1 a2 b
a a a a a a
...@@ -1960,46 +1963,46 @@ c e ...@@ -1960,46 +1963,46 @@ c e
d e d e
explain select distinct a1,a2,b from t1; explain select distinct a1,a2,b from t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using index for group-by
explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by
explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by; Using temporary; Using filesort 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by
explain select distinct a1,a2,b from t2; explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by; Using temporary; Using filesort 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by; Using temporary; Using filesort
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL # Using where; Using index for group-by
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL # Using where; Using index for group-by
select distinct a1,a2,b from t1; select distinct a1,a2,b from t1;
a1 a2 b a1 a2 b
a a a a a a
...@@ -2082,21 +2085,21 @@ select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1; ...@@ -2082,21 +2085,21 @@ select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
a1 a1
explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 501 Using where; Using index for group-by (scanning) 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by
explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 100.00 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 100.00 Using where; Using index for group-by
Warnings: Warnings:
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' 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'); 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); explain extended select 98 + 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 100.00 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 100.00 Using where; Using index for group-by
Warnings: Warnings:
Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a' Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + 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'); select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
...@@ -2116,19 +2119,19 @@ select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); ...@@ -2116,19 +2119,19 @@ select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
104 104
explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 126 Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; select 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)) a1 a2 b concat(min(c), max(c))
a a a a111d111 a a a a111d111
...@@ -2197,83 +2200,83 @@ concat(ord(min(b)),ord(max(b))) min(b) max(b) ...@@ -2197,83 +2200,83 @@ concat(ord(min(b)),ord(max(b))) min(b) max(b)
9798 a b 9798 a b
explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128
explain select a1,a2,b,d from t1 group by a1,a2,b; explain select a1,a2,b,d from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128
explain extended select a1,a2,min(b),max(b) from t1 explain extended select a1,a2,min(b),max(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; where (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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where; Using index
Warnings: Warnings:
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` 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 t1 explain extended 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') and (d > 'xy2') group by a1,a2,b; where (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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where
Warnings: Warnings:
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` 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 t1 explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; where (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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where
Warnings: Warnings:
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` 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; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b < 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b' and b >= 'a') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b' and b >= 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where; Using index
Warnings: Warnings:
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` 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; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
a1 a2 min(b) c a1 a2 min(b) c
a a a a111 a a a a111
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,min(c),max(c) from t2 explain select a1,a2,b,min(c),max(c) from t2
where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b; where (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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c; explain 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 1000 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128
explain select a1,a2,count(a2) from t1 group by a1,a2,b; explain select a1,a2,count(a2) from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; explain 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index
Warnings: Warnings:
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` 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; 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index
Warnings: Warnings:
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` 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 a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select distinct(a1) from t1 where ord(a2) = 98; explain select distinct(a1) from t1 where ord(a2) = 98;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
select distinct(a1) from t1 where ord(a2) = 98; select distinct(a1) from t1 where ord(a2) = 98;
a1 a1
a a
...@@ -2282,7 +2285,7 @@ c ...@@ -2282,7 +2285,7 @@ c
d d
explain select a1 from t1 where a2 = 'b' group by a1; explain select a1 from t1 where a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
select a1 from t1 where a2 = 'b' group by a1; select a1 from t1 where a2 = 'b' group by a1;
a1 a1
a a
...@@ -2291,7 +2294,7 @@ c ...@@ -2291,7 +2294,7 @@ c
d d
explain select distinct a1 from t1 where a2 = 'b'; explain select distinct a1 from t1 where a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 63 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
select distinct a1 from t1 where a2 = 'b'; select distinct a1 from t1 where a2 = 'b';
a1 a1
a a
...@@ -2463,10 +2466,11 @@ CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) engine=RocksDB; ...@@ -2463,10 +2466,11 @@ CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) engine=RocksDB;
INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3); INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 501 Using where; Using index for group-by 1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 500 Using where; Using index for group-by
SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
MAX(b) a MAX(b) a
1 1 1 1
...@@ -2477,10 +2481,11 @@ CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)) engine=RocksDB; ...@@ -2477,10 +2481,11 @@ CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)) engine=RocksDB;
INSERT INTO t2 SELECT a,b,b FROM t1; INSERT INTO t2 SELECT a,b,b FROM t1;
ANALYZE TABLE t2; ANALYZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK test.t2 analyze status OK
explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 251 Using where; Using index for group-by 1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 500 Using where; Using index for group-by
SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
MIN(c) MIN(c)
2 2
...@@ -2490,10 +2495,11 @@ INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5), ...@@ -2490,10 +2495,11 @@ 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); (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
FLUSH STATUS; FLUSH STATUS;
SELECT max(b), a FROM t1 GROUP BY a; SELECT max(b), a FROM t1 GROUP BY a;
max(b) a max(b) a
...@@ -2508,7 +2514,7 @@ Handler_read_next 0 ...@@ -2508,7 +2514,7 @@ Handler_read_next 0
Handler_read_retry 0 Handler_read_retry 0
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
FLUSH STATUS; FLUSH STATUS;
CREATE TABLE t2 engine=RocksDB SELECT max(b), a FROM t1 GROUP BY a; CREATE TABLE t2 engine=RocksDB SELECT max(b), a FROM t1 GROUP BY a;
SHOW STATUS LIKE 'handler_read__e%'; SHOW STATUS LIKE 'handler_read__e%';
...@@ -2544,54 +2550,54 @@ Handler_read_retry 0 ...@@ -2544,54 +2550,54 @@ Handler_read_retry 0
EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
(SELECT max(b), a FROM t1 GROUP BY a); (SELECT max(b), a FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range NULL a 5 NULL 251 Using index for group-by 1 PRIMARY t1 range NULL a 5 NULL 6 Using index for group-by
2 UNION t1 range NULL a 5 NULL 251 Using index for group-by 2 UNION t1 range NULL a 5 NULL 6 Using index for group-by
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
FROM t1 AS t1_outer; FROM t1 AS t1_outer;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 1000 Using index 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 251 Using index for group-by 2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 1000 Using index 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 index NULL a 10 NULL 1000 Using index 2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 1000 Using index 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 251 Using index for group-by 2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 251 1 PRIMARY t1_outer index a a 10 NULL 15 Using where; Using index
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 4 Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1_outer.a 1
2 MATERIALIZED t1 range NULL a 5 NULL 251 Using index for group-by 2 MATERIALIZED t1 range a a 5 NULL 400 Using where; Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer range NULL a 5 NULL 251 Using index for group-by 1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by
2 SUBQUERY t1 range NULL a 5 NULL 251 Using index for group-by 2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 EXPLAIN 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) ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
AND t1_outer1.b = t1_outer2.b; AND t1_outer1.b = t1_outer2.b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer1 ref a a 5 const 4 Using where; Using index 1 PRIMARY t1_outer1 ref a a 5 const 3 Using where; Using index
1 PRIMARY t1_outer2 index NULL a 10 NULL 1000 Using where; Using index; Using join buffer (flat, BNL join) 1 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 251 Using index for group-by 2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer2 index NULL a 10 NULL 1000 Using index 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
2 SUBQUERY t1_outer index NULL a 10 NULL 1000 Using index 2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
3 SUBQUERY t1 range NULL a 5 NULL 251 Using index for group-by 3 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by
CREATE TABLE t3 LIKE t1; CREATE TABLE t3 LIKE t1;
FLUSH STATUS; FLUSH STATUS;
INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
SHOW STATUS LIKE 'handler_read__e%'; SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value Variable_name Value
Handler_read_key 8 Handler_read_key 13
Handler_read_next 0 Handler_read_next 0
Handler_read_retry 0 Handler_read_retry 0
DELETE FROM t3; DELETE FROM t3;
...@@ -2626,10 +2632,11 @@ INSERT INTO t1 VALUES ...@@ -2626,10 +2632,11 @@ INSERT INTO t1 VALUES
(4), (2), (1), (2), (2), (4), (1), (4); (4), (2), (1), (2), (2), (4), (1), (4);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN SELECT DISTINCT(a) FROM t1; EXPLAIN SELECT DISTINCT(a) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx 5 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL idx 5 NULL 4 Using index for group-by
SELECT DISTINCT(a) FROM t1; SELECT DISTINCT(a) FROM t1;
a a
1 1
...@@ -2637,7 +2644,7 @@ a ...@@ -2637,7 +2644,7 @@ a
4 4
EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx 5 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL idx 5 NULL 4 Using index for group-by
SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
a a
1 1
...@@ -2650,11 +2657,12 @@ INSERT INTO t1 SELECT a + 1, b FROM t1; ...@@ -2650,11 +2657,12 @@ INSERT INTO t1 SELECT a + 1, b FROM t1;
INSERT INTO t1 SELECT a + 2, b FROM t1; INSERT INTO t1 SELECT a + 2, b FROM t1;
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN EXPLAIN
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 Using temporary; Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
a MIN(b) MAX(b) a MIN(b) MAX(b)
4 1 3 4 1 3
...@@ -2665,7 +2673,7 @@ CREATE INDEX break_it ON t1 (a, b); ...@@ -2665,7 +2673,7 @@ CREATE INDEX break_it ON t1 (a, b);
EXPLAIN EXPLAIN
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL break_it 10 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL break_it 10 NULL 4 Using index for group-by
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
a MIN(b) MAX(b) a MIN(b) MAX(b)
1 1 3 1 1 3
...@@ -2675,7 +2683,7 @@ a MIN(b) MAX(b) ...@@ -2675,7 +2683,7 @@ a MIN(b) MAX(b)
EXPLAIN EXPLAIN
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL break_it 10 NULL 251 Using index for group-by; Using temporary; Using filesort 1 SIMPLE t1 range NULL break_it 10 NULL 4 Using index for group-by; Using temporary; Using filesort
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
a MIN(b) MAX(b) a MIN(b) MAX(b)
4 1 3 4 1 3
...@@ -2685,7 +2693,7 @@ a MIN(b) MAX(b) ...@@ -2685,7 +2693,7 @@ a MIN(b) MAX(b)
EXPLAIN EXPLAIN
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL break_it 10 NULL 1000 Using index 1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
a MIN(b) MAX(b) AVG(b) a MIN(b) MAX(b) AVG(b)
4 1 3 2.0000 4 1 3 2.0000
...@@ -2706,6 +2714,7 @@ insert into t1 (a,b) values ...@@ -2706,6 +2714,7 @@ insert into t1 (a,b) values
insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a; insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
select * from t1; select * from t1;
a b a b
...@@ -2768,7 +2777,7 @@ a b ...@@ -2768,7 +2777,7 @@ a b
3 13 3 13
explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; explain 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 Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref PRIMARY,index PRIMARY 4 const 15 100.00 Using index; Using temporary 1 SIMPLE t1 ref PRIMARY,index PRIMARY 4 const 15 6.67 Using index; Using temporary
Warnings: Warnings:
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` 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; drop table t1;
...@@ -2780,10 +2789,11 @@ INSERT INTO t1 SELECT * FROM t1; ...@@ -2780,10 +2789,11 @@ INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT a,b,c+1,d FROM t1; INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4; EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL foo 10 NULL 63 Using where; Using index for group-by 1 SIMPLE t1 range NULL foo 10 NULL 3 Using where; Using index for group-by
SELECT DISTINCT c FROM t1 WHERE d=4; SELECT DISTINCT c FROM t1 WHERE d=4;
c c
1 1
...@@ -2799,13 +2809,14 @@ INSERT INTO t SELECT * FROM t; ...@@ -2799,13 +2809,14 @@ INSERT INTO t SELECT * FROM t;
INSERT INTO t SELECT * FROM t; INSERT INTO t SELECT * FROM t;
ANALYZE TABLE t; ANALYZE TABLE t;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t analyze status Engine-independent statistics collected
test.t analyze status OK test.t analyze status OK
# test MIN # test MIN
#should use range with index for group by #should use range with index for group by
EXPLAIN EXPLAIN
SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range NULL a 10 NULL 251 Using where; Using index for group-by 1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
#should return 1 row #should return 1 row
SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
a MIN(b) a MIN(b)
...@@ -2815,7 +2826,7 @@ a MIN(b) ...@@ -2815,7 +2826,7 @@ a MIN(b)
EXPLAIN EXPLAIN
SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range NULL a 10 NULL 251 Using where; Using index for group-by 1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
#should return 1 row #should return 1 row
SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
a MAX(b) a MAX(b)
...@@ -2826,7 +2837,7 @@ INSERT INTO t SELECT a, 2 FROM t; ...@@ -2826,7 +2837,7 @@ INSERT INTO t SELECT a, 2 FROM t;
EXPLAIN EXPLAIN
SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range NULL a 10 NULL 251 Using where; Using index for group-by 1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
#should return 1 row #should return 1 row
SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
a MAX(b) a MAX(b)
...@@ -2841,6 +2852,7 @@ INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); ...@@ -2841,6 +2852,7 @@ INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
INSERT INTO t SELECT * FROM t; INSERT INTO t SELECT * FROM t;
ANALYZE TABLE t; ANALYZE TABLE t;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t analyze status Engine-independent statistics collected
test.t analyze status OK test.t analyze status OK
SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a; SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a;
a MAX(b) a MAX(b)
...@@ -2862,6 +2874,7 @@ CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)) engine=RocksDB; ...@@ -2862,6 +2874,7 @@ CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)) engine=RocksDB;
INSERT INTO t1 VALUES(1,1),(2,1); INSERT INTO t1 VALUES(1,1),(2,1);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b; SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;
c b c b
...@@ -2880,6 +2893,7 @@ CREATE TABLE t1 ( a INT, KEY (a) ) engine=RocksDB; ...@@ -2880,6 +2893,7 @@ CREATE TABLE t1 ( a INT, KEY (a) ) engine=RocksDB;
INSERT INTO t1 VALUES (1), (2), (3); INSERT INTO t1 VALUES (1), (2), (3);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = NULL; SELECT MIN( a ) FROM t1 WHERE a = NULL;
...@@ -2940,7 +2954,7 @@ NULL ...@@ -2940,7 +2954,7 @@ NULL
EXPLAIN EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Using where; Using index x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using where; Using index x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a ) MIN( a )
...@@ -2955,6 +2969,7 @@ NULL ...@@ -2955,6 +2969,7 @@ NULL
INSERT INTO t1 VALUES (NULL), (NULL); INSERT INTO t1 VALUES (NULL), (NULL);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = NULL; SELECT MIN( a ) FROM t1 WHERE a = NULL;
...@@ -3015,7 +3030,7 @@ NULL ...@@ -3015,7 +3030,7 @@ NULL
EXPLAIN EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Using where; Using index x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using where; Using index x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a ) MIN( a )
...@@ -3033,6 +3048,7 @@ CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY) engine=RocksDB; ...@@ -3033,6 +3048,7 @@ CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY) engine=RocksDB;
INSERT INTO t1 VALUES (1), (2), (3); INSERT INTO t1 VALUES (1), (2), (3);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
# #
# NULL-safe operator test disabled for non-NULL indexed columns. # NULL-safe operator test disabled for non-NULL indexed columns.
...@@ -3097,7 +3113,7 @@ NULL ...@@ -3097,7 +3113,7 @@ NULL
EXPLAIN EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT 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 Extra id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Using where; Using index x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using where; Using index x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a ) MIN( a )
...@@ -3133,6 +3149,7 @@ INSERT INTO t1 SELECT a, b + 4, 1 FROM t1; ...@@ -3133,6 +3149,7 @@ INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
INSERT INTO t1 SELECT a + 1, b, 1 FROM t1; INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)) engine=RocksDB; CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)) engine=RocksDB;
INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1), INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
...@@ -3141,48 +3158,49 @@ INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2; ...@@ -3141,48 +3158,49 @@ INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2;
INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2; INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2;
ANALYZE TABLE t2; ANALYZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK test.t2 analyze status OK
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1; EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
SELECT COUNT(DISTINCT a) FROM t1; SELECT COUNT(DISTINCT a) FROM t1;
COUNT(DISTINCT a) COUNT(DISTINCT a)
2 2
EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1; EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 10 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT a,b) FROM t1; SELECT COUNT(DISTINCT a,b) FROM t1;
COUNT(DISTINCT a,b) COUNT(DISTINCT a,b)
16 16
EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1; EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 10 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT b,a) FROM t1; SELECT COUNT(DISTINCT b,a) FROM t1;
COUNT(DISTINCT b,a) COUNT(DISTINCT b,a)
16 16
EXPLAIN SELECT COUNT(DISTINCT b) FROM t1; EXPLAIN SELECT COUNT(DISTINCT b) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 10 NULL 1000 Using index 1 SIMPLE t1 index NULL a 10 NULL 16 Using index
SELECT COUNT(DISTINCT b) FROM t1; SELECT COUNT(DISTINCT b) FROM t1;
COUNT(DISTINCT b) COUNT(DISTINCT b)
8 8
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
COUNT(DISTINCT a) COUNT(DISTINCT a)
1 1
1 1
EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 10 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
COUNT(DISTINCT b) COUNT(DISTINCT b)
8 8
8 8
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 10 NULL 1000 Using index; Using filesort 1 SIMPLE t1 index NULL a 10 NULL 16 Using index; Using filesort
SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
COUNT(DISTINCT a) COUNT(DISTINCT a)
2 2
...@@ -3195,94 +3213,94 @@ COUNT(DISTINCT a) ...@@ -3195,94 +3213,94 @@ COUNT(DISTINCT a)
2 2
EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1; EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 10 NULL 1000 Using index 1 SIMPLE t1 index NULL a 10 NULL 16 Using index
SELECT DISTINCT COUNT(DISTINCT a) FROM t1; SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
COUNT(DISTINCT a) COUNT(DISTINCT a)
2 2
EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1; EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 10 NULL 1000 Using index 1 SIMPLE t1 index NULL a 10 NULL 16 Using index
SELECT COUNT(DISTINCT a, b + 0) FROM t1; SELECT COUNT(DISTINCT a, b + 0) FROM t1;
COUNT(DISTINCT a, b + 0) COUNT(DISTINCT a, b + 0)
16 16
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10; EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 10 NULL 1000 Using index 1 SIMPLE t1 index NULL a 10 NULL 16 Using index
SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10; SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
COUNT(DISTINCT a) COUNT(DISTINCT a)
2 2
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1 SIMPLE t1 ALL NULL NULL NULL NULL 16
SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
COUNT(DISTINCT a) COUNT(DISTINCT a)
2 2
EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
1 1
1 1
EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 10 NULL 501 Using index for group-by 1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
1 1
1 1
1 1
EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1_1 index NULL a 10 NULL 1000 Using index; Using temporary; Using filesort 1 SIMPLE t1_1 index NULL a 10 NULL 16 Using index; Using temporary; Using filesort
1 SIMPLE t1_2 index NULL a 10 NULL 1000 Using index; Using join buffer (flat, BNL join) 1 SIMPLE t1_2 index NULL a 10 NULL 16 Using index; Using join buffer (flat, BNL join)
SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
COUNT(DISTINCT t1_1.a) COUNT(DISTINCT t1_1.a)
1 1
1 1
EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1; EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 5 NULL 251 Using index for group-by 1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
SELECT COUNT(DISTINCT a), 12 FROM t1; SELECT COUNT(DISTINCT a), 12 FROM t1;
COUNT(DISTINCT a) 12 COUNT(DISTINCT a) 12
2 12 2 12
EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 15 NULL 501 Using index for group-by 1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT a, b, c) FROM t2; SELECT COUNT(DISTINCT a, b, c) FROM t2;
COUNT(DISTINCT a, b, c) COUNT(DISTINCT a, b, c)
16 16
EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 5 NULL 126 Using index for group-by 1 SIMPLE t2 range NULL a 5 NULL 3 Using index for group-by
SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a)
2 3 1.5000 2 3 1.5000
EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 1 SIMPLE t2 ALL NULL NULL NULL NULL 16
SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f) COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f)
2 3 1.0000 2 3 1.0000
EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 10 NULL 251 Using index for group-by 1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
COUNT(DISTINCT a, b) COUNT(DISTINCT b, a) COUNT(DISTINCT a, b) COUNT(DISTINCT b, a)
16 16 16 16
EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 1 SIMPLE t2 ALL NULL NULL NULL NULL 16
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
COUNT(DISTINCT a, b) COUNT(DISTINCT b, f) COUNT(DISTINCT a, b) COUNT(DISTINCT b, f)
16 8 16 8
EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 1 SIMPLE t2 ALL NULL NULL NULL NULL 16
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
COUNT(DISTINCT a, b) COUNT(DISTINCT b, d) COUNT(DISTINCT a, b) COUNT(DISTINCT b, d)
16 8 16 8
EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 15 NULL 501 Using index for group-by 1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
a c COUNT(DISTINCT c, a, b) a c COUNT(DISTINCT c, a, b)
1 1 1 1 1 1
...@@ -3304,7 +3322,7 @@ a c COUNT(DISTINCT c, a, b) ...@@ -3304,7 +3322,7 @@ a c COUNT(DISTINCT c, a, b)
EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2 EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range a a 15 NULL 501 Using where; Using index for group-by 1 SIMPLE t2 range a a 15 NULL 1062 Using where; Using index for group-by (scanning)
SELECT COUNT(DISTINCT c, a, b) FROM t2 SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
COUNT(DISTINCT c, a, b) COUNT(DISTINCT c, a, b)
...@@ -3317,28 +3335,28 @@ GROUP BY b; ...@@ -3317,28 +3335,28 @@ GROUP BY b;
COUNT(DISTINCT b) SUM(DISTINCT b) COUNT(DISTINCT b) SUM(DISTINCT b)
EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 10 NULL 251 Using index for group-by 1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
a COUNT(DISTINCT b) SUM(DISTINCT b) a COUNT(DISTINCT b) SUM(DISTINCT b)
1 8 36 1 8 36
2 8 36 2 8 36
EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 10 NULL 251 Using index for group-by 1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
COUNT(DISTINCT b) SUM(DISTINCT b) COUNT(DISTINCT b) SUM(DISTINCT b)
8 36 8 36
8 36 8 36
EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 16 Using where
SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
COUNT(DISTINCT a, b) COUNT(DISTINCT a, b)
0 0
EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
WHERE b = 13 AND c = 42 GROUP BY a; WHERE b = 13 AND c = 42 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 15 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range NULL a 15 NULL 3 Using where; Using index for group-by
SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
WHERE b = 13 AND c = 42 GROUP BY a; WHERE b = 13 AND c = 42 GROUP BY a;
a COUNT(DISTINCT a) SUM(DISTINCT a) a COUNT(DISTINCT a) SUM(DISTINCT a)
...@@ -3346,20 +3364,20 @@ a COUNT(DISTINCT a) SUM(DISTINCT a) ...@@ -3346,20 +3364,20 @@ a COUNT(DISTINCT a) SUM(DISTINCT a)
# the second part of count(..) is defined by a constant predicate # the second part of count(..) is defined by a constant predicate
EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL a 15 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL a 15 NULL 16 Using where; Using index
SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
COUNT(DISTINCT a, b) SUM(DISTINCT a) COUNT(DISTINCT a, b) SUM(DISTINCT a)
0 NULL 0 NULL
EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL a 15 NULL 1000 Using index 1 SIMPLE t2 index NULL a 15 NULL 16 Using index
SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
SUM(DISTINCT a) MAX(b) SUM(DISTINCT a) MAX(b)
1 8 1 8
2 8 2 8
EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 15 NULL 501 Using index for group-by 1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
42 * (a + c + COUNT(DISTINCT c, a, b)) 42 * (a + c + COUNT(DISTINCT c, a, b))
126 126
...@@ -3380,7 +3398,7 @@ SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; ...@@ -3380,7 +3398,7 @@ SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
168 168
EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL a 15 NULL 1000 Using index 1 SIMPLE t2 index NULL a 15 NULL 16 Using index
SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
(SUM(DISTINCT a) + MAX(b)) (SUM(DISTINCT a) + MAX(b))
9 9
...@@ -3400,6 +3418,7 @@ insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'), ...@@ -3400,6 +3418,7 @@ insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D'); (3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
f1 COUNT(DISTINCT f2) f1 COUNT(DISTINCT f2)
...@@ -3408,7 +3427,7 @@ f1 COUNT(DISTINCT f2) ...@@ -3408,7 +3427,7 @@ f1 COUNT(DISTINCT f2)
3 4 3 4
explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 5 NULL 1000 Using index 1 SIMPLE t1 index NULL PRIMARY 5 NULL 8 Using index
drop table t1; drop table t1;
# End of test#50539. # End of test#50539.
# #
...@@ -3419,9 +3438,11 @@ CREATE TABLE t (a INT, b INT, KEY(a,b)) engine=RocksDB; ...@@ -3419,9 +3438,11 @@ CREATE TABLE t (a INT, b INT, KEY(a,b)) engine=RocksDB;
INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5); INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5);
ANALYZE TABLE t; ANALYZE TABLE t;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t analyze status Engine-independent statistics collected
test.t analyze status OK test.t analyze status OK
ANALYZE TABLE t; ANALYZE TABLE t;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t analyze status Engine-independent statistics collected
test.t analyze status OK test.t analyze status OK
SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
a SUM(DISTINCT a) MIN(b) a SUM(DISTINCT a) MIN(b)
...@@ -3431,7 +3452,7 @@ a SUM(DISTINCT a) MIN(b) ...@@ -3431,7 +3452,7 @@ a SUM(DISTINCT a) MIN(b)
4 4 4 4 4 4
EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL a 10 NULL 1000 Using index 1 SIMPLE t index NULL a 10 NULL 7 Using index
SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
a SUM(DISTINCT a) MAX(b) a SUM(DISTINCT a) MAX(b)
1 1 1 1 1 1
...@@ -3440,7 +3461,7 @@ a SUM(DISTINCT a) MAX(b) ...@@ -3440,7 +3461,7 @@ a SUM(DISTINCT a) MAX(b)
4 4 5 4 4 5
EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL a 10 NULL 1000 Using index 1 SIMPLE t index NULL a 10 NULL 7 Using index
SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
a MAX(b) a MAX(b)
1 1 1 1
...@@ -3449,13 +3470,13 @@ a MAX(b) ...@@ -3449,13 +3470,13 @@ a MAX(b)
4 5 4 5
EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL a 10 NULL 1000 Using index 1 SIMPLE t index NULL a 10 NULL 7 Using index
SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
SUM(DISTINCT a) MIN(b) MAX(b) SUM(DISTINCT a) MIN(b) MAX(b)
10 0 5 10 0 5
EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL a 10 NULL 1000 Using index 1 SIMPLE t index NULL a 10 NULL 7 Using index
SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
a SUM(DISTINCT a) MIN(b) MAX(b) a SUM(DISTINCT a) MIN(b) MAX(b)
1 1 0 1 1 1 0 1
...@@ -3464,7 +3485,7 @@ a SUM(DISTINCT a) MIN(b) MAX(b) ...@@ -3464,7 +3485,7 @@ a SUM(DISTINCT a) MIN(b) MAX(b)
4 4 4 5 4 4 4 5
EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL a 10 NULL 1000 Using index 1 SIMPLE t index NULL a 10 NULL 7 Using index
DROP TABLE t; DROP TABLE t;
# #
# Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD # Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD
...@@ -3480,6 +3501,7 @@ INSERT INTO t1(c1,c2) VALUES ...@@ -3480,6 +3501,7 @@ INSERT INTO t1(c1,c2) VALUES
(4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5); (4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5);
ANALYZE TABLE t1; ANALYZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK test.t1 analyze status OK
EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment