|
|
|
@@ -1707,13 +1707,13 @@ select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1
|
|
|
|
|
a1 a2 b
|
|
|
|
|
explain select distinct a1,a2,b from t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 50.78 Using where; Using index
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 100.00 Using where; Using index
|
|
|
|
|
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'))
|
|
|
|
|
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
|
|
|
|
@@ -1724,13 +1724,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
|
|
|
|
|
explain select distinct a1,a2,b from t2;
|
|
|
|
|
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 index NULL idx_t2_2 146 NULL # Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
|
|
|
|
|
1 SIMPLE t2 index NULL idx_t2_2 146 NULL # Using where; Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 50.61 Using where; Using index
|
|
|
|
|
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 100.00 Using where; Using index
|
|
|
|
|
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'))
|
|
|
|
|
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
|
|
|
|
@@ -1855,7 +1855,7 @@ c e
|
|
|
|
|
d e
|
|
|
|
|
explain select distinct a1,a2,b from t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
|
|
|
@@ -1870,7 +1870,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
|
|
|
|
|
explain select distinct a1,a2,b from t2;
|
|
|
|
|
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 index NULL idx_t2_2 146 NULL # Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
|
|
|
|
@@ -1953,10 +1953,10 @@ 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
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by (scanning)
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by
|
|
|
|
@@ -2173,7 +2173,7 @@ c
|
|
|
|
|
d
|
|
|
|
|
explain select distinct a1 from t1 where a2 = 'b';
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
|
|
|
|
|
select distinct a1 from t1 where a2 = 'b';
|
|
|
|
|
a1
|
|
|
|
|
a
|
|
|
|
@@ -2283,7 +2283,7 @@ INSERT INTO t1 (a) VALUES
|
|
|
|
|
('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
|
|
|
|
|
EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 66 NULL 6 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 66 NULL 11 Using index
|
|
|
|
|
SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
|
|
|
|
a a
|
|
|
|
|
|
|
|
|
@@ -2499,7 +2499,7 @@ INSERT INTO t1 VALUES
|
|
|
|
|
(4), (2), (1), (2), (2), (4), (1), (4);
|
|
|
|
|
EXPLAIN SELECT DISTINCT(a) FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx 5 NULL 16 Using index
|
|
|
|
|
SELECT DISTINCT(a) FROM t1;
|
|
|
|
|
a
|
|
|
|
|
1
|
|
|
|
@@ -2507,7 +2507,7 @@ a
|
|
|
|
|
4
|
|
|
|
|
EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL idx 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL idx 5 NULL 16 Using index
|
|
|
|
|
SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
|
|
|
|
|
a
|
|
|
|
|
1
|
|
|
|
@@ -2646,7 +2646,7 @@ INSERT INTO t1 SELECT * FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
|
|
|
|
|
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL foo 10 NULL 9 Using where; Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL foo 20 NULL 32 Using where; Using index
|
|
|
|
|
SELECT DISTINCT c FROM t1 WHERE d=4;
|
|
|
|
|
c
|
|
|
|
|
1
|
|
|
|
@@ -3339,19 +3339,19 @@ 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;
|
|
|
|
|
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a) FROM t1;
|
|
|
|
|
COUNT(DISTINCT a)
|
|
|
|
|
2
|
|
|
|
|
EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 10 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a,b) FROM t1;
|
|
|
|
|
COUNT(DISTINCT a,b)
|
|
|
|
|
16
|
|
|
|
|
EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 10 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT b,a) FROM t1;
|
|
|
|
|
COUNT(DISTINCT b,a)
|
|
|
|
|
16
|
|
|
|
@@ -3414,7 +3414,7 @@ COUNT(DISTINCT a)
|
|
|
|
|
2
|
|
|
|
|
EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
|
|
|
|
SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
|
|
|
|
|
1
|
|
|
|
|
1
|
|
|
|
@@ -3435,19 +3435,19 @@ COUNT(DISTINCT t1_1.a)
|
|
|
|
|
1
|
|
|
|
|
EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t1 range NULL a 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a), 12 FROM t1;
|
|
|
|
|
COUNT(DISTINCT a) 12
|
|
|
|
|
2 12
|
|
|
|
|
EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2;
|
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
|
1 SIMPLE t2 range NULL a 15 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t2 index NULL a 15 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a, b, c) FROM t2;
|
|
|
|
|
COUNT(DISTINCT a, b, c)
|
|
|
|
|
16
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t2 range NULL a 5 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t2 index NULL a 15 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
|
|
|
|
|
COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a)
|
|
|
|
|
2 3 1.5000
|
|
|
|
@@ -3459,7 +3459,7 @@ COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f)
|
|
|
|
|
2 3 1.0000
|
|
|
|
|
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
|
|
|
|
|
1 SIMPLE t2 range NULL a 10 NULL 9 Using index for group-by
|
|
|
|
|
1 SIMPLE t2 index NULL a 15 NULL 16 Using index
|
|
|
|
|
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
|
|
|
|
|
COUNT(DISTINCT a, b) COUNT(DISTINCT b, a)
|
|
|
|
|
16 16
|
|
|
|
|