mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-16188 Use in-memory PK filters built from range index scans
This patch contains a full implementation of the optimization
that allows to use in-memory rowid / primary filters built for range
conditions over indexes. In many cases usage of such filters reduce
the number of disk seeks spent for fetching table rows.
In this implementation the choice of what possible filter to be applied
(if any) is made purely on cost-based considerations.
This implementation re-achitectured the partial implementation of
the feature pushed by Galina Shalygina in the commit
8d5a11122c
.
Besides this patch contains a better implementation of the generic
handler function handler::multi_range_read_info_const() that
takes into account gaps between ranges when calculating the cost of
range index scans. It also contains some corrections of the
implementation of the handler function records_in_range() for MyISAM.
This patch supports the feature for InnoDB and MyISAM.
This commit is contained in:
@ -152,5 +152,6 @@ typedef enum icp_result {
|
||||
} ICP_RESULT;
|
||||
|
||||
typedef ICP_RESULT (*index_cond_func_t)(void *param);
|
||||
typedef int (*rowid_filter_func_t)(void *param);
|
||||
|
||||
#endif /* _my_compare_h */
|
||||
|
@ -158,7 +158,7 @@ CREATE TABLE t1 ( a int PRIMARY KEY );
|
||||
--let $query = DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
--let $select = SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
--source include/explain_utils.inc
|
||||
INSERT INTO t1 VALUES (1), (2), (3);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (-1), (-2), (-3);
|
||||
--let $query = DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
--let $select = SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
--source include/explain_utils.inc
|
||||
@ -640,7 +640,7 @@ DROP VIEW v1;
|
||||
|
||||
--echo #63
|
||||
CREATE TABLE t1 (a INT, PRIMARY KEY(a));
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9);
|
||||
CREATE VIEW v1 (a) AS SELECT a FROM t1;
|
||||
--let $query = DELETE FROM v1 WHERE a < 4
|
||||
--let $select = SELECT * FROM v1 WHERE a < 4
|
||||
|
@ -633,6 +633,8 @@ CREATE TABLE t2 (
|
||||
);
|
||||
INSERT INTO t2 VALUES (4,1);
|
||||
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
|
||||
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
|
||||
@ -840,6 +842,8 @@ INSERT INTO t2 (g,h) VALUES
|
||||
(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
|
||||
(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u');
|
||||
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
SET @save_optimize_switch=@@optimizer_switch;
|
||||
SET optimizer_switch='materialization=on';
|
||||
|
||||
|
@ -57,12 +57,12 @@ update t0 set key2=key1,key3=key1,key4=key1,key5=key1,key6=key1,key7=key1,key8=1
|
||||
analyze table t0;
|
||||
|
||||
# 1. One index
|
||||
explain select * from t0 where key1 < 3 or key1 > 1020;
|
||||
explain select * from t0 where key1 < 3 or key1 > 920 and key1 < 924;
|
||||
|
||||
# 2. Simple cases
|
||||
explain
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
select * from t0 where key1 < 3 or key2 > 920 and key2 < 924;
|
||||
select * from t0 where key1 < 3 or key2 > 920 and key2 < 924;
|
||||
|
||||
select * from t0 where key1=1022; # MDEV-13535 no-key-read select after keyread
|
||||
|
||||
@ -115,7 +115,6 @@ select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
|
||||
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
|
||||
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2);
|
||||
|
||||
@ -146,6 +145,10 @@ select * from t0 where
|
||||
key1 < 7;
|
||||
|
||||
# tree_or(List<SEL_IMERGE>, List<SEL_IMERGE>).
|
||||
select count(*) from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
|
||||
or
|
||||
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
|
||||
explain select * from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
|
||||
or
|
||||
|
@ -315,7 +315,7 @@ ANALYZE
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["pk"],
|
||||
"r_loops": 1,
|
||||
"rows": 11,
|
||||
"rows": 10,
|
||||
"r_rows": 10,
|
||||
"r_total_time_ms": "REPLACED",
|
||||
"filtered": 100,
|
||||
@ -340,7 +340,7 @@ ANALYZE
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["pk"],
|
||||
"rows": 11,
|
||||
"rows": 10,
|
||||
"r_rows": 10,
|
||||
"r_filtered": 50,
|
||||
"r_total_time_ms": "REPLACED",
|
||||
|
@ -62,7 +62,7 @@ ANALYZE
|
||||
explain
|
||||
update t2 set a=a+1 where a<10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL 8 Using where; Using buffer
|
||||
1 SIMPLE t2 range a a 5 NULL 9 Using where; Using buffer
|
||||
explain format=json
|
||||
update t2 set a=a+1 where a<10;
|
||||
EXPLAIN
|
||||
@ -78,7 +78,7 @@ EXPLAIN
|
||||
"key": "a",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 8,
|
||||
"rows": 9,
|
||||
"attached_condition": "t2.a < 10"
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ ANALYZE
|
||||
"key": "a",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 8,
|
||||
"rows": 9,
|
||||
"r_rows": 10,
|
||||
"r_filtered": 100,
|
||||
"r_total_time_ms": "REPLACED",
|
||||
|
@ -2766,11 +2766,11 @@ KEY(date_column));
|
||||
INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition
|
||||
ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 2 Using index condition
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
|
@ -3175,11 +3175,11 @@ KEY(date_column));
|
||||
INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition
|
||||
ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 2 Using index condition
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
|
@ -3472,11 +3472,11 @@ KEY(date_column));
|
||||
INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition
|
||||
ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 2 Using index condition
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
|
@ -256,10 +256,10 @@ t1 CREATE TABLE `t1` (
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 23 NULL 2 Using where; Using index
|
||||
explain select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 23 NULL 2 Using where; Using index
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
@ -1557,7 +1557,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index
|
||||
EXPLAIN SELECT * FROM t1 WHERE a LIKE 'c%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 23 NULL 30 Using where; Using index
|
||||
1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a LIKE 'c%';
|
||||
a
|
||||
ca
|
||||
@ -1573,7 +1573,7 @@ ch
|
||||
ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_croatian_ci;
|
||||
EXPLAIN SELECT * FROM t1 WHERE a LIKE 'd%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 23 NULL 30 Using where; Using index
|
||||
1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index
|
||||
SELECT hex(concat('d',_ucs2 0x017E,'%'));
|
||||
hex(concat('d',_ucs2 0x017E,'%'))
|
||||
0064017E0025
|
||||
@ -4356,11 +4356,11 @@ KEY(date_column));
|
||||
INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition
|
||||
ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 2 Using index condition
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
|
@ -133,10 +133,10 @@ t1 CREATE TABLE `t1` (
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
explain select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
|
@ -3999,7 +3999,7 @@ D801DC28 30D2 𐐨
|
||||
ALTER TABLE t1 ADD KEY(c);
|
||||
EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range c c 43 NULL 2 Using where; Using index
|
||||
1 SIMPLE t1 range c c 43 NULL 3 Using where; Using index
|
||||
SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
|
||||
hex(c) hex(weight_string(c))
|
||||
0061 120F
|
||||
|
@ -136,10 +136,10 @@ t1 CREATE TABLE `t1` (
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
explain select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
|
@ -132,10 +132,10 @@ t1 CREATE TABLE `t1` (
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
explain select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using index
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
|
@ -4019,7 +4019,7 @@ hex(c) hex(weight_string(c)) c
|
||||
ALTER TABLE t1 ADD KEY(c);
|
||||
EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range c c 43 NULL 2 Using where; Using index
|
||||
1 SIMPLE t1 range c c 43 NULL 3 Using where; Using index
|
||||
SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
|
||||
hex(c) hex(weight_string(c))
|
||||
00000061 120F
|
||||
|
@ -5223,11 +5223,11 @@ KEY(date_column));
|
||||
INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 4 NULL 2 Using index condition
|
||||
ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range date_column date_column 6 NULL 2 Using index condition
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
|
@ -7778,7 +7778,7 @@ EXPLAIN
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["pk"],
|
||||
"rows": 2,
|
||||
"rows": 1,
|
||||
"filtered": 100,
|
||||
"index_condition": "t.pk > 2"
|
||||
}
|
||||
@ -14981,7 +14981,7 @@ from t1 join
|
||||
on t1.a=t.a
|
||||
where t1.b <= 5;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL idx_b NULL NULL NULL 12 75.00 Using where
|
||||
1 PRIMARY t1 ALL idx_b NULL NULL NULL 12 83.33 Using where
|
||||
1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 9 100.00
|
||||
2 DERIVED t2 ALL idx_a NULL NULL NULL 90 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
@ -15000,7 +15000,7 @@ EXPLAIN
|
||||
"access_type": "ALL",
|
||||
"possible_keys": ["idx_b"],
|
||||
"rows": 12,
|
||||
"filtered": 75,
|
||||
"filtered": 83.333,
|
||||
"attached_condition": "t1.b <= 5 and t1.a is not null"
|
||||
},
|
||||
"table": {
|
||||
@ -15174,7 +15174,7 @@ from t3 join
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b > 15;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t3 range idx_b idx_b 5 NULL 3 100.00 Using index condition; Using where
|
||||
1 PRIMARY t3 range idx_b idx_b 5 NULL 2 100.00 Using index condition; Using where
|
||||
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 100.00
|
||||
2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00
|
||||
Warnings:
|
||||
@ -15195,7 +15195,7 @@ EXPLAIN
|
||||
"key": "idx_b",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["b"],
|
||||
"rows": 3,
|
||||
"rows": 2,
|
||||
"filtered": 100,
|
||||
"index_condition": "t3.b > 15",
|
||||
"attached_condition": "t3.a is not null and t3.c is not null"
|
||||
@ -15252,7 +15252,7 @@ from t3 join
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b <= 15;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 75.00 Using where
|
||||
1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 83.33 Using where
|
||||
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 4 100.00
|
||||
2 DERIVED t4 ALL idx NULL NULL NULL 40 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
@ -15271,7 +15271,7 @@ EXPLAIN
|
||||
"access_type": "ALL",
|
||||
"possible_keys": ["idx_b"],
|
||||
"rows": 12,
|
||||
"filtered": 75,
|
||||
"filtered": 83.333,
|
||||
"attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null"
|
||||
},
|
||||
"table": {
|
||||
@ -15326,7 +15326,7 @@ from t3 join
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b > 15;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t3 range idx_b idx_b 5 NULL 3 100.00 Using index condition; Using where
|
||||
1 PRIMARY t3 range idx_b idx_b 5 NULL 2 100.00 Using index condition; Using where
|
||||
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 100.00
|
||||
2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00
|
||||
Warnings:
|
||||
@ -15347,7 +15347,7 @@ EXPLAIN
|
||||
"key": "idx_b",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["b"],
|
||||
"rows": 3,
|
||||
"rows": 2,
|
||||
"filtered": 100,
|
||||
"index_condition": "t3.b > 15",
|
||||
"attached_condition": "t3.a is not null and t3.c is not null"
|
||||
@ -15404,7 +15404,7 @@ from t3 join
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b <= 15;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 75.00 Using where
|
||||
1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 83.33 Using where
|
||||
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 4 100.00
|
||||
2 DERIVED t4 ALL idx NULL NULL NULL 40 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
@ -15423,7 +15423,7 @@ EXPLAIN
|
||||
"access_type": "ALL",
|
||||
"possible_keys": ["idx_b"],
|
||||
"rows": 12,
|
||||
"filtered": 75,
|
||||
"filtered": 83.333,
|
||||
"attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null"
|
||||
},
|
||||
"table": {
|
||||
|
@ -534,7 +534,7 @@ LEFT JOIN
|
||||
ON t2.id=t.id
|
||||
WHERE t2.id < 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 3 Using index condition
|
||||
1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition
|
||||
1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
|
||||
set join_cache_level=default;
|
||||
|
@ -13,7 +13,7 @@ id str
|
||||
3 foo
|
||||
explain select * from t1 where str is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref str str 11 const 1 Using index condition
|
||||
1 SIMPLE t1 ref str str 11 const 2 Using index condition
|
||||
explain select * from t1 where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
@ -311,9 +311,15 @@ INSERT INTO t1 VALUES(4, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(3, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(2, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(1, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(5, 2, 1, 1);
|
||||
INSERT INTO t1 VALUES(6, 2, 1, 1);
|
||||
INSERT INTO t1 VALUES(7, 3, 1, 1);
|
||||
INSERT INTO t1 VALUES(9, 3, 1, 1);
|
||||
INSERT INTO t1 VALUES(10, 4, 1, 1);
|
||||
INSERT INTO t1 VALUES(11, 4, 1, 1);
|
||||
EXPLAIN SELECT c1 FROM t1 WHERE c2 = 1 AND c4 = 1 AND c5 = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c2,c2_2 c2 10 const,const 3 Using where
|
||||
1 SIMPLE t1 ref c2,c2_2 c2 10 const,const 4 Using where
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#56814 Explain + subselect + fulltext crashes server
|
||||
|
@ -238,6 +238,12 @@ INSERT INTO t1 VALUES(4, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(3, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(2, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(1, 1, 1, 1);
|
||||
INSERT INTO t1 VALUES(5, 2, 1, 1);
|
||||
INSERT INTO t1 VALUES(6, 2, 1, 1);
|
||||
INSERT INTO t1 VALUES(7, 3, 1, 1);
|
||||
INSERT INTO t1 VALUES(9, 3, 1, 1);
|
||||
INSERT INTO t1 VALUES(10, 4, 1, 1);
|
||||
INSERT INTO t1 VALUES(11, 4, 1, 1);
|
||||
|
||||
EXPLAIN SELECT c1 FROM t1 WHERE c2 = 1 AND c4 = 1 AND c5 = 1;
|
||||
|
||||
|
@ -739,7 +739,7 @@ EXPLAIN
|
||||
"key": "a",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 1,
|
||||
"rows": 2,
|
||||
"filtered": 100,
|
||||
"index_condition": "t1.a < 3",
|
||||
"mrr_type": "Rowid-ordered scan"
|
||||
|
@ -612,12 +612,12 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain
|
||||
select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range k1 k1 3 NULL 6 Using where; Using index
|
||||
1 SIMPLE t1 range k1 k1 3 NULL 7 Using where; Using index
|
||||
explain
|
||||
select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
|
||||
select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'DEN' and t2.a3 >= 'LA';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range k1 k1 7 NULL 1 Using where; Using index
|
||||
1 SIMPLE t2 range k1 k1 3 NULL 4 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t2 range k1 k1 3 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
explain
|
||||
select min(a4 - 0.01) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain
|
||||
select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index
|
||||
1 SIMPLE t2 index k2 k2 4 NULL 7 Using where; Using index
|
||||
1 SIMPLE t1 index NULL PRIMARY 3 NULL 15 Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1, t2;
|
||||
create table t1 (a char(10));
|
||||
@ -1333,10 +1333,11 @@ SELECT MIN(a), MIN(b) FROM t1;
|
||||
MIN(a) MIN(b)
|
||||
NULL 1
|
||||
CREATE TABLE t2( a INT, b INT, c INT, KEY(a, b) );
|
||||
INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 );
|
||||
INSERT INTO t2 ( a, b, c ) VALUES
|
||||
( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ), ( 2, NULL, 2 ), ( 2, 3, 4 ), ( 2, 4, 4 );
|
||||
EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref a a 5 const 2
|
||||
1 SIMPLE t2 ref a a 5 const 3
|
||||
SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
|
||||
MIN(b) MIN(c)
|
||||
3 2
|
||||
@ -1839,12 +1840,12 @@ End of 5.1 tests
|
||||
# Bug #904345: MIN/MAX optimization with constant FALSE condition
|
||||
#
|
||||
CREATE TABLE t1 (a int NOT NULL, KEY(a));
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9);
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9), (13), (15), (17);
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(8,2), (6,9), (8,4), (5,3), (9,1);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<8;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
@ -1857,7 +1858,7 @@ EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00
|
||||
1 PRIMARY t1 range a a 4 NULL 4 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 range a a 4 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = 1 and `test`.`t2`.`b` = 2 and `test`.`t1`.`a` < 10
|
||||
@ -1867,7 +1868,7 @@ NULL
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 4 100.00 Using where; Using index
|
||||
1 SIMPLE t1 range a a 4 NULL 3 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where rand() * 0 <> 0 and `test`.`t1`.`a` < 10
|
||||
SELECT MAX(a) FROM t1 WHERE RAND()*0<>0 AND a<10;
|
||||
|
@ -363,7 +363,7 @@ select min(a1) from t1 where a1 != 'KKK';
|
||||
explain
|
||||
select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
|
||||
explain
|
||||
select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
|
||||
select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'DEN' and t2.a3 >= 'LA';
|
||||
|
||||
explain
|
||||
select min(a4 - 0.01) from t1;
|
||||
@ -849,7 +849,8 @@ EXPLAIN SELECT MIN(a), MIN(b) FROM t1;
|
||||
SELECT MIN(a), MIN(b) FROM t1;
|
||||
|
||||
CREATE TABLE t2( a INT, b INT, c INT, KEY(a, b) );
|
||||
INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 );
|
||||
INSERT INTO t2 ( a, b, c ) VALUES
|
||||
( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ), ( 2, NULL, 2 ), ( 2, 3, 4 ), ( 2, 4, 4 );
|
||||
EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
|
||||
SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
|
||||
|
||||
@ -1168,14 +1169,14 @@ drop table t1;
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int NOT NULL, KEY(a));
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9);
|
||||
INSERT INTO t1 VALUES (10), (8), (11), (7), (15), (12), (9), (13), (15), (17);
|
||||
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(8,2), (6,9), (8,4), (5,3), (9,1);
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<8;
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
|
||||
EXPLAIN EXTENDED
|
||||
|
@ -1,3 +1,8 @@
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
|
||||
insert into t1 values (1, 3);
|
||||
select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
|
||||
@ -237,7 +242,9 @@ SET storage_engine=@old_engine;
|
||||
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
|
||||
KEY(b, c, a(765))) ENGINE=INNODB;
|
||||
INSERT INTO t1(a, b, c) VALUES
|
||||
('', 'a', 0), ('', 'a', null), ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
|
||||
('', 'a', 0), ('', 'a', null), ('', 'a', 0), ('', 'a', null), ('', 'a', 0),
|
||||
('', 'a', 1), ('', 'a', 1), ('', 'a', 2), ('', 'a', 2), ('', 'a', 3),
|
||||
('', 'a', 3), ('', 'a', 4), ('', 'a', 4), ('', 'a', 5), ('', 'a', 5);
|
||||
ANALYZE TABLE t1;
|
||||
SELECT MIN(c) FROM t1 GROUP BY b;
|
||||
MIN(c)
|
||||
@ -247,3 +254,6 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL b 263 NULL 3 Using index for group-by
|
||||
DROP TABLE t1;
|
||||
End of 5.5 tests
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
--disable_warnings
|
||||
create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
|
||||
--enable_warnings
|
||||
@ -181,7 +188,9 @@ SET storage_engine=@old_engine;
|
||||
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
|
||||
KEY(b, c, a(765))) ENGINE=INNODB;
|
||||
INSERT INTO t1(a, b, c) VALUES
|
||||
('', 'a', 0), ('', 'a', null), ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
|
||||
('', 'a', 0), ('', 'a', null), ('', 'a', 0), ('', 'a', null), ('', 'a', 0),
|
||||
('', 'a', 1), ('', 'a', 1), ('', 'a', 2), ('', 'a', 2), ('', 'a', 3),
|
||||
('', 'a', 3), ('', 'a', 4), ('', 'a', 4), ('', 'a', 5), ('', 'a', 5);
|
||||
|
||||
-- disable_result_log
|
||||
ANALYZE TABLE t1;
|
||||
@ -193,3 +202,7 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -241,7 +241,7 @@ insert into t2 select C.a*2+1, 'yes' from t1 C;
|
||||
explain
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL 12 Using index condition
|
||||
1 SIMPLE t2 range a a 5 NULL 11 Using index condition
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
a filler
|
||||
1 yes
|
||||
@ -271,7 +271,7 @@ select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 6 NULL 12 Using index condition
|
||||
1 SIMPLE t2 range a a 6 NULL 11 Using index condition
|
||||
select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
@ -295,7 +295,7 @@ insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
|
||||
('barbas','1'), ('bazbazbay', '1'),('zz','1');
|
||||
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 13 NULL 7 Using index condition
|
||||
1 SIMPLE t2 range a a 13 NULL 6 Using index condition
|
||||
drop table t2;
|
||||
create table t2 (a decimal(10,5), filler char(200), key(a));
|
||||
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
|
||||
@ -306,7 +306,7 @@ insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'),
|
||||
explain
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 7 NULL 7 Using index condition
|
||||
1 SIMPLE t2 range a a 7 NULL 6 Using index condition
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
a filler
|
||||
0.00000 1
|
||||
|
@ -3,12 +3,12 @@ create table t1 (a varchar(10), key(a));
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain extended select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like 'abc%'
|
||||
explain extended select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like <cache>(concat('abc','%'))
|
||||
select * from t1 where a like "abc%";
|
||||
|
@ -1423,7 +1423,7 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id
|
||||
WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index
|
||||
1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index
|
||||
1 SIMPLE t1 ref code code 13 const 4 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`code` = 'a12' and octet_length(`test`.`t1`.`code`) = 5
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -2429,7 +2429,11 @@ a int,
|
||||
b varchar(1),
|
||||
KEY (b,a)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a');
|
||||
INSERT INTO t1 VALUES
|
||||
(1,NULL),(0,'a'),(1,NULL),(0,'a'), (1,'a'),(0,'a'),(2,'a'),(1,'a');
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
|
||||
EXPLAIN SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -1545,7 +1545,9 @@ CREATE TABLE t1 (
|
||||
b varchar(1),
|
||||
KEY (b,a)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a');
|
||||
INSERT INTO t1 VALUES
|
||||
(1,NULL),(0,'a'),(1,NULL),(0,'a'), (1,'a'),(0,'a'),(2,'a'),(1,'a');
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
let $query=
|
||||
SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
|
||||
|
@ -317,7 +317,7 @@ 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 14 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;
|
||||
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 14 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 13 Using where; Using index for group-by
|
||||
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
|
||||
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
|
||||
@ -1653,7 +1653,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
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 14 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 13 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;
|
||||
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
|
||||
@ -1718,7 +1718,7 @@ 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');
|
||||
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 14 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 13 Using where; Using index for group-by
|
||||
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
|
||||
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
|
||||
@ -1864,7 +1864,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
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 14 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 13 Using where; Using index for group-by
|
||||
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
|
||||
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
|
||||
@ -1959,7 +1959,7 @@ 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)
|
||||
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
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 100.00 Using where; Using index for group-by
|
||||
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'
|
||||
explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
|
||||
@ -1967,7 +1967,7 @@ 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 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
|
||||
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
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 100.00 Using where; Using index for group-by
|
||||
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'
|
||||
select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
|
||||
@ -2075,19 +2075,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
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 130 NULL 76 85.53 Using where; Using index
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 85.71 Using where; Using index
|
||||
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`
|
||||
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;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 51.56 Using where; Using temporary; Using filesort
|
||||
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`
|
||||
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;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 50.78 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 51.56 Using where; Using temporary; Using filesort
|
||||
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`
|
||||
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
|
||||
@ -2095,7 +2095,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
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;
|
||||
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 130 NULL 76 85.53 Using where; Using index
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 85.71 Using where; Using index
|
||||
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`
|
||||
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
|
||||
@ -2119,12 +2119,12 @@ 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 index
|
||||
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
|
||||
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 101 95.05 Using where; Using index
|
||||
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`
|
||||
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
|
||||
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 101 95.05 Using where; Using index
|
||||
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`
|
||||
create table t4 as select distinct a1, a2, b, c from t1;
|
||||
@ -2225,7 +2225,7 @@ a
|
||||
BB
|
||||
EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 3 Using where; Using index
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 4 Using where; Using index
|
||||
EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using index
|
||||
@ -2281,9 +2281,15 @@ INSERT INTO t1 (a) VALUES
|
||||
(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
|
||||
('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
|
||||
('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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 range NULL a 66 NULL 12 Using index for group-by
|
||||
SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
||||
a a
|
||||
|
||||
@ -2342,10 +2348,15 @@ id2 id3 id5 id4 id3 id6 id5 id1
|
||||
1 1 1 1 1 1 1 1
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6;
|
||||
CREATE TABLE t1 (a int, b int, KEY (a,b), KEY b (b));
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1),(1,2),(1,0),(1,3),
|
||||
(1,-1),(1,-2),(1,-3),(1,-4);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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
|
||||
1 SIMPLE t1 range a,b a 10 NULL 1 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range a,b a 10 NULL 2 Using where; Using index for group-by
|
||||
SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
|
||||
MAX(b) a
|
||||
1 1
|
||||
@ -2364,9 +2375,12 @@ DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 SIMPLE t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
FLUSH STATUS;
|
||||
SELECT max(b), a FROM t1 GROUP BY a;
|
||||
max(b) a
|
||||
@ -2381,7 +2395,7 @@ Handler_read_next 0
|
||||
Handler_read_retry 0
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 SIMPLE t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
FLUSH STATUS;
|
||||
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
@ -2417,14 +2431,14 @@ Handler_read_retry 0
|
||||
EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
|
||||
(SELECT max(b), a FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 UNION t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 PRIMARY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
2 UNION t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
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
|
||||
FROM t1 AS t1_outer;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -2434,31 +2448,31 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 4
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 4 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
|
||||
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 PRIMARY t1_outer range NULL a 5 NULL 4 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
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)
|
||||
AND t1_outer1.b = t1_outer2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
|
||||
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 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
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;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
|
||||
3 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
3 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
CREATE TABLE t3 LIKE t1;
|
||||
FLUSH STATUS;
|
||||
INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
|
||||
@ -2497,9 +2511,12 @@ CREATE TABLE t1 (a int, INDEX idx(a));
|
||||
INSERT INTO t1 VALUES
|
||||
(4), (2), (1), (2), (4), (2), (1), (4),
|
||||
(4), (2), (1), (2), (2), (4), (1), (4);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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 range NULL idx 5 NULL 4 Using index for group-by
|
||||
SELECT DISTINCT(a) FROM t1;
|
||||
a
|
||||
1
|
||||
@ -2507,7 +2524,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 range NULL idx 5 NULL 4 Using index for group-by
|
||||
SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
|
||||
a
|
||||
1
|
||||
@ -2515,19 +2532,22 @@ a
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5);
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b)
|
||||
4 1 3
|
||||
3 1 3
|
||||
2 1 3
|
||||
1 1 3
|
||||
4 1 5
|
||||
3 1 5
|
||||
2 1 5
|
||||
1 1 5
|
||||
CREATE INDEX break_it ON t1 (a, b);
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
@ -2535,30 +2555,30 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
a MIN(b) MAX(b)
|
||||
1 1 3
|
||||
2 1 3
|
||||
3 1 3
|
||||
4 1 3
|
||||
1 1 5
|
||||
2 1 5
|
||||
3 1 5
|
||||
4 1 5
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by; Using temporary; Using filesort
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b)
|
||||
4 1 3
|
||||
3 1 3
|
||||
2 1 3
|
||||
1 1 3
|
||||
4 1 5
|
||||
3 1 5
|
||||
2 1 5
|
||||
1 1 5
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
|
||||
1 SIMPLE t1 index NULL break_it 10 NULL 20 Using index
|
||||
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b) AVG(b)
|
||||
4 1 3 2.0000
|
||||
3 1 3 2.0000
|
||||
2 1 3 2.0000
|
||||
1 1 3 2.0000
|
||||
4 1 5 3.0000
|
||||
3 1 5 3.0000
|
||||
2 1 5 3.0000
|
||||
1 1 5 3.0000
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int, key (a,b), key `index` (a,b)) engine=MyISAM;
|
||||
Warnings:
|
||||
@ -2644,9 +2664,12 @@ INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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 range NULL foo 10 NULL 3 Using where; Using index for group-by
|
||||
SELECT DISTINCT c FROM t1 WHERE d=4;
|
||||
c
|
||||
1
|
||||
@ -2660,12 +2683,15 @@ CREATE TABLE t (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
|
||||
INSERT INTO t SELECT * FROM t;
|
||||
INSERT INTO t SELECT * FROM t;
|
||||
ANALYZE TABLE t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t analyze status OK
|
||||
# test MIN
|
||||
#should use range with index for group by
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t range NULL a 10 NULL 9 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
|
||||
SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
|
||||
a MIN(b)
|
||||
@ -2675,7 +2701,7 @@ a MIN(b)
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t range NULL a 10 NULL 9 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
|
||||
SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
|
||||
a MAX(b)
|
||||
@ -2686,7 +2712,7 @@ INSERT INTO t SELECT a, 2 FROM t;
|
||||
EXPLAIN
|
||||
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
|
||||
1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t range NULL a 10 NULL 3 Using where; Using index for group-by
|
||||
#should return 1 row
|
||||
SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
|
||||
a MAX(b)
|
||||
@ -3295,10 +3321,14 @@ INSERT INTO t1 VALUES (0,99),(9,99),(4,0),(7,0),(99,0),(7,0),(8,0),(99,0),(1,0);
|
||||
INSERT INTO t1 VALUES (0,99),(9,99),(4,0),(7,0),(99,0),(7,0),(8,0),(99,0),(1,0);
|
||||
CREATE TABLE t2 (c int) ;
|
||||
INSERT INTO t2 VALUES (0),(1);
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT MIN(a), b FROM t1 WHERE a > 0 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL b 10 NULL 10 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL b 10 NULL 3 Using where; Using index for group-by
|
||||
SELECT MIN(a), b FROM t1 WHERE a > 0 GROUP BY b;
|
||||
MIN(a) b
|
||||
1 0
|
||||
@ -3306,7 +3336,7 @@ MIN(a) b
|
||||
EXPLAIN
|
||||
SELECT MIN(a), b FROM t1 WHERE a > ( SELECT c FROM t2 WHERE c = 0 ) GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL b 10 NULL 10 Using where; Using index for group-by
|
||||
1 PRIMARY t1 range NULL b 10 NULL 3 Using where; Using index for group-by
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT MIN(a), b FROM t1 WHERE a > ( SELECT c FROM t2 WHERE c = 0 ) GROUP BY b;
|
||||
MIN(a) b
|
||||
@ -3330,54 +3360,66 @@ End of 5.3 tests
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b));
|
||||
INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b + 8, 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
|
||||
CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c));
|
||||
INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
|
||||
(1,4,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), (1,4,1,1,1,1);
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
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;
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
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 range NULL a 5 NULL 3 Using index for group-by
|
||||
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 range NULL a 10 NULL 33 Using index for group-by
|
||||
SELECT COUNT(DISTINCT a,b) FROM t1;
|
||||
COUNT(DISTINCT a,b)
|
||||
16
|
||||
32
|
||||
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 range NULL a 10 NULL 33 Using index for group-by
|
||||
SELECT COUNT(DISTINCT b,a) FROM t1;
|
||||
COUNT(DISTINCT b,a)
|
||||
16
|
||||
32
|
||||
EXPLAIN SELECT COUNT(DISTINCT b) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
||||
1 SIMPLE t1 index NULL a 10 NULL 256 Using index
|
||||
SELECT COUNT(DISTINCT b) FROM t1;
|
||||
COUNT(DISTINCT b)
|
||||
8
|
||||
16
|
||||
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
|
||||
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 range NULL a 5 NULL 3 Using index for group-by
|
||||
SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
|
||||
COUNT(DISTINCT a)
|
||||
1
|
||||
1
|
||||
EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
|
||||
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 range NULL a 10 NULL 33 Using index for group-by
|
||||
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
|
||||
COUNT(DISTINCT b)
|
||||
8
|
||||
8
|
||||
16
|
||||
16
|
||||
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 10 NULL 16 Using index; Using filesort
|
||||
1 SIMPLE t1 index NULL a 10 NULL 256 Using index; Using filesort
|
||||
SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
|
||||
COUNT(DISTINCT a)
|
||||
2
|
||||
@ -3388,96 +3430,103 @@ COUNT(DISTINCT a)
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
||||
1 SIMPLE t1 index NULL a 10 NULL 256 Using index
|
||||
SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
|
||||
COUNT(DISTINCT a)
|
||||
2
|
||||
EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
||||
1 SIMPLE t1 index NULL a 10 NULL 256 Using index
|
||||
SELECT COUNT(DISTINCT a, b + 0) FROM t1;
|
||||
COUNT(DISTINCT a, b + 0)
|
||||
16
|
||||
32
|
||||
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
|
||||
1 SIMPLE t1 index NULL a 10 NULL 16 Using index
|
||||
1 SIMPLE t1 index NULL a 10 NULL 256 Using index
|
||||
SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
|
||||
COUNT(DISTINCT a)
|
||||
2
|
||||
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
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 16
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 256
|
||||
SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
|
||||
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 range NULL a 5 NULL 3 Using index for group-by
|
||||
SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
|
||||
1
|
||||
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
|
||||
1 SIMPLE t1 range NULL a 10 NULL 9 Using index for group-by
|
||||
1 SIMPLE t1 range NULL a 10 NULL 33 Using index for group-by
|
||||
SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
|
||||
1
|
||||
1
|
||||
1
|
||||
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
|
||||
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 16 Using index; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1_1 index NULL a 10 NULL 256 Using index; Using temporary; Using filesort
|
||||
1 SIMPLE t1_2 index NULL a 10 NULL 256 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;
|
||||
COUNT(DISTINCT t1_1.a)
|
||||
1
|
||||
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 range NULL a 5 NULL 3 Using index for group-by
|
||||
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 range NULL a 15 NULL 17 Using index for group-by
|
||||
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 range NULL a 5 NULL 3 Using index for group-by
|
||||
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
|
||||
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
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 16
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 256
|
||||
SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
|
||||
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 range NULL a 10 NULL 17 Using index for group-by
|
||||
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
|
||||
COUNT(DISTINCT a, b) COUNT(DISTINCT b, a)
|
||||
16 16
|
||||
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
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 16
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 256
|
||||
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
|
||||
COUNT(DISTINCT a, b) COUNT(DISTINCT b, f)
|
||||
16 8
|
||||
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
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 16
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 256
|
||||
SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
|
||||
COUNT(DISTINCT a, b) COUNT(DISTINCT b, d)
|
||||
16 8
|
||||
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
|
||||
1 SIMPLE t2 range NULL a 15 NULL 9 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;
|
||||
a c COUNT(DISTINCT c, a, b)
|
||||
1 1 1
|
||||
@ -3499,7 +3548,7 @@ a c COUNT(DISTINCT c, a, b)
|
||||
EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
|
||||
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
|
||||
1 SIMPLE t2 range a a 15 NULL 1 Using where; Using index for group-by
|
||||
1 SIMPLE t2 range a a 5 NULL 1 Using where; Using index
|
||||
SELECT COUNT(DISTINCT c, a, b) FROM t2
|
||||
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
|
||||
COUNT(DISTINCT c, a, b)
|
||||
@ -3512,47 +3561,47 @@ GROUP BY b;
|
||||
COUNT(DISTINCT b) SUM(DISTINCT b)
|
||||
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
|
||||
1 SIMPLE t2 range NULL a 10 NULL 9 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;
|
||||
a COUNT(DISTINCT b) SUM(DISTINCT b)
|
||||
1 8 36
|
||||
2 8 36
|
||||
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
|
||||
1 SIMPLE t2 range NULL a 10 NULL 9 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;
|
||||
COUNT(DISTINCT b) SUM(DISTINCT b)
|
||||
8 36
|
||||
8 36
|
||||
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
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 16 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 256 Using where
|
||||
SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
|
||||
COUNT(DISTINCT a, b)
|
||||
0
|
||||
EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
|
||||
WHERE b = 13 AND c = 42 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range NULL a 15 NULL 9 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
|
||||
WHERE b = 13 AND c = 42 GROUP BY a;
|
||||
a COUNT(DISTINCT a) SUM(DISTINCT a)
|
||||
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
|
||||
1 SIMPLE t2 index NULL a 15 NULL 16 Using where; Using index
|
||||
1 SIMPLE t2 index NULL a 15 NULL 256 Using where; Using index
|
||||
SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
|
||||
COUNT(DISTINCT a, b) SUM(DISTINCT a)
|
||||
0 NULL
|
||||
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
|
||||
1 SIMPLE t2 index NULL a 15 NULL 16 Using index
|
||||
1 SIMPLE t2 index NULL a 15 NULL 256 Using index
|
||||
SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
|
||||
SUM(DISTINCT a) MAX(b)
|
||||
1 8
|
||||
2 8
|
||||
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
|
||||
1 SIMPLE t2 range NULL a 15 NULL 9 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;
|
||||
42 * (a + c + COUNT(DISTINCT c, a, b))
|
||||
126
|
||||
@ -3573,7 +3622,7 @@ SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
|
||||
168
|
||||
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
|
||||
1 SIMPLE t2 index NULL a 15 NULL 16 Using index
|
||||
1 SIMPLE t2 index NULL a 15 NULL 256 Using index
|
||||
SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
|
||||
(SUM(DISTINCT a) + MAX(b))
|
||||
9
|
||||
@ -3682,8 +3731,12 @@ b c
|
||||
drop table faulty;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
CREATE INDEX break_it ON t1 (a, b);
|
||||
EXPLAIN
|
||||
SELECT distinct a, b FROM t1 where a = '3' ORDER BY b;
|
||||
@ -3739,24 +3792,28 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables=PREFERABLY;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 4 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 8 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 4 100.00 Using index for group-by
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1_outer`.`a` AS `a` from <materialize> (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 4 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 8 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 4 100.00 Using index for group-by
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1_outer`.`a` AS `a` from <materialize> (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
|
||||
drop table t1;
|
||||
@ -3786,15 +3843,18 @@ INSERT INTO t1 VALUES (4,'2001-01-01');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-02');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-03');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-04');
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>='2001-01-04' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL id 8 NULL 5 Using where; Using index for group-by
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104.0 GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL id 8 NULL 5 Using where; Using index for group-by
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL id 8 NULL 5 Using where; Using index for group-by
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>='2001-01-04' GROUP BY id;
|
||||
id MIN(a) MAX(a)
|
||||
1 2001-01-04 2001-01-04
|
||||
@ -3835,6 +3895,11 @@ INSERT INTO t1 VALUES (4,'2001-01-01');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-02');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-03');
|
||||
INSERT INTO t1 VALUES (4,' 2001-01-04');
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN ' 2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
id MIN(a) MAX(a)
|
||||
1 2001-01-04 2001-01-03
|
||||
@ -3890,19 +3955,19 @@ id MIN(a) MAX(a)
|
||||
4 2001-01-04 2001-01-04
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN ' 2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL id 27 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL id 27 NULL 10 Using where; Using index for group-by
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN '2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL id 27 NULL 9 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range NULL id 27 NULL 10 Using where; Using index for group-by
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN DATE'2001-01-04' AND DATE'2001-01-05' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL id 27 NULL 16 Using where; Using index
|
||||
1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN DATE'2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL id 27 NULL 16 Using where; Using index
|
||||
1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN '2001-01-04' AND DATE'2001-01-05' GROUP BY id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL id 27 NULL 16 Using where; Using index
|
||||
1 SIMPLE t1 index NULL id 27 NULL 64 Using where; Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MIN() optimization didn't work correctly with BETWEEN when using too
|
||||
|
@ -835,6 +835,10 @@ INSERT INTO t1 (a) VALUES
|
||||
(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
|
||||
('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
|
||||
('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
||||
SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
||||
@ -893,7 +897,10 @@ DROP TABLE t1,t2,t3,t4,t5,t6;
|
||||
# Bug#22342: No results returned for query using max and group by
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int, KEY (a,b), KEY b (b));
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1),(1,2),(1,0),(1,3),
|
||||
(1,-1),(1,-2),(1,-3),(1,-4);
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
explain 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;
|
||||
@ -912,6 +919,7 @@ DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
ANALYZE TABLE t1;
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
FLUSH STATUS;
|
||||
SELECT max(b), a FROM t1 GROUP BY a;
|
||||
@ -975,6 +983,7 @@ CREATE TABLE t1 (a int, INDEX idx(a));
|
||||
INSERT INTO t1 VALUES
|
||||
(4), (2), (1), (2), (4), (2), (1), (4),
|
||||
(4), (2), (1), (2), (2), (4), (1), (4);
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
EXPLAIN SELECT DISTINCT(a) FROM t1;
|
||||
SELECT DISTINCT(a) FROM t1;
|
||||
@ -988,9 +997,10 @@ DROP TABLE t1;
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5);
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
@ -1044,6 +1054,7 @@ INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
#Should be non-empty
|
||||
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
|
||||
@ -1060,6 +1071,7 @@ CREATE TABLE t (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
|
||||
INSERT INTO t SELECT * FROM t;
|
||||
INSERT INTO t SELECT * FROM t;
|
||||
ANALYZE TABLE t;
|
||||
|
||||
--echo # test MIN
|
||||
--echo #should use range with index for group by
|
||||
@ -1262,6 +1274,7 @@ INSERT INTO t1 VALUES (0,99),(9,99),(4,0),(7,0),(99,0),(7,0),(8,0),(99,0),(1,0);
|
||||
INSERT INTO t1 VALUES (0,99),(9,99),(4,0),(7,0),(99,0),(7,0),(8,0),(99,0),(1,0);
|
||||
CREATE TABLE t2 (c int) ;
|
||||
INSERT INTO t2 VALUES (0),(1);
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
EXPLAIN
|
||||
SELECT MIN(a), b FROM t1 WHERE a > 0 GROUP BY b;
|
||||
@ -1284,13 +1297,22 @@ drop table t1, t2;
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b));
|
||||
INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b + 8, 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
|
||||
CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c));
|
||||
INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
|
||||
(1,4,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), (1,4,1,1,1,1);
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
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;
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
|
||||
SELECT COUNT(DISTINCT a) FROM t1;
|
||||
@ -1479,8 +1501,10 @@ drop table faulty;
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
CREATE INDEX break_it ON t1 (a, b);
|
||||
|
||||
@ -1527,6 +1551,8 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
@ -1566,6 +1592,7 @@ INSERT INTO t1 VALUES (4,'2001-01-01');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-02');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-03');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-04');
|
||||
ANALYZE TABLE t1;
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>='2001-01-04' GROUP BY id;
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104.0 GROUP BY id;
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
|
||||
@ -1595,6 +1622,9 @@ INSERT INTO t1 VALUES (4,'2001-01-01');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-02');
|
||||
INSERT INTO t1 VALUES (4,'2001-01-03');
|
||||
INSERT INTO t1 VALUES (4,' 2001-01-04');
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1;
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN ' 2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN '2001-01-04' AND '2001-01-05' GROUP BY id;
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a BETWEEN DATE'2001-01-04' AND DATE'2001-01-05' GROUP BY id;
|
||||
|
@ -1,3 +1,8 @@
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
drop view if exists v1;
|
||||
drop table if exists t1,t4;
|
||||
create table t4 (
|
||||
@ -194,7 +199,7 @@ EXPLAIN SELECT c1, i1, max(i2) FROM t2
|
||||
WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )
|
||||
GROUP BY c1,i1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range k2 k2 5 NULL 60 Using where; Using index
|
||||
1 SIMPLE t2 range k2 k2 9 NULL 60 Using where; Using index for group-by
|
||||
SELECT c1, i1, max(i2) FROM t2
|
||||
WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )
|
||||
GROUP BY c1,i1;
|
||||
@ -205,7 +210,7 @@ EXPLAIN SELECT c1, i1, max(i2) FROM t2
|
||||
WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ))
|
||||
GROUP BY c1,i1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range k2 k2 5 NULL 60 Using where; Using index
|
||||
1 SIMPLE t2 range k2 k2 9 NULL 60 Using where; Using index for group-by
|
||||
SELECT c1, i1, max(i2) FROM t2
|
||||
WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ))
|
||||
GROUP BY c1,i1;
|
||||
@ -302,3 +307,6 @@ NULL bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
NULL aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
NULL aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
drop table t1,t2;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -6,6 +6,13 @@
|
||||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
--disable_warnings
|
||||
drop view if exists v1;
|
||||
drop table if exists t1,t4;
|
||||
@ -243,3 +250,8 @@ CREATE TABLE t2 (`voter_id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
insert into t2 values (1,repeat("a",1000)),(2,repeat("a",1000)),(3,repeat("b",1000)),(4,repeat("c",1000)),(4,repeat("b",1000));
|
||||
SELECT GROUP_CONCAT(t1.language_id SEPARATOR ',') AS `translation_resources`, `d`.`serialized_c` FROM t2 AS `d` LEFT JOIN t1 ON `d`.`voter_id` = t1.`voter_id` GROUP BY `d`.`voter_id` ORDER BY 10-d.voter_id+RAND()*0;
|
||||
drop table t1,t2;
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
||||
|
@ -38,6 +38,7 @@ SELECT COUNT(*) FROM CountryLanguage;
|
||||
COUNT(*)
|
||||
984
|
||||
CREATE INDEX Name ON City(Name);
|
||||
SET SESSION optimizer_switch='rowid_filter=off';
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
SELECT COUNT(*) FROM City;
|
||||
COUNT(*)
|
||||
@ -357,6 +358,9 @@ COUNT(*)
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'B%';
|
||||
COUNT(*)
|
||||
339
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'J%';
|
||||
COUNT(*)
|
||||
256
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
|
||||
@ -364,7 +368,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
|
||||
EXPLAIN
|
||||
@ -383,15 +387,13 @@ ID Name Country Population
|
||||
1810 Montréal CAN 1016376
|
||||
2259 Medellín COL 1861265
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
@ -465,9 +467,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL # Using sort_intersect(Country,Population); Using where
|
||||
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
|
||||
@ -494,33 +496,11 @@ WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
554 Santiago de Chile CHL 4703954
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
|
||||
ID Name Country Population
|
||||
@ -726,7 +706,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
|
||||
EXPLAIN
|
||||
@ -736,9 +716,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL # Using sort_intersect(Country,Population); Using where
|
||||
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
@ -778,10 +758,9 @@ ID Name Country Population
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
@ -794,19 +773,8 @@ ID Name Country Population
|
||||
1937 Huainan CHN 700000
|
||||
1950 Hegang CHN 520000
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
AND Country BETWEEN 'S' AND 'Z';
|
||||
@ -888,12 +856,12 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL # Using sort_intersect(CountryName,Population); Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
@ -931,73 +899,37 @@ ID Name Country Population
|
||||
2698 Maputo MOZ 1018938
|
||||
2710 Rangoon (Yangon) MMR 3361700
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
ID Name Country Population
|
||||
1890 Shanghai CHN 9696300
|
||||
1891 Peking CHN 7472000
|
||||
1892 Chongqing CHN 6351600
|
||||
1893 Tianjin CHN 5286800
|
||||
1894 Wuhan CHN 4344600
|
||||
1895 Harbin CHN 4289800
|
||||
1896 Shenyang CHN 4265200
|
||||
1897 Kanton [Guangzhou] CHN 4256300
|
||||
1898 Chengdu CHN 3361500
|
||||
1899 Nanking [Nanjing] CHN 2870300
|
||||
1900 Changchun CHN 2812000
|
||||
1901 Xi´an CHN 2761400
|
||||
1902 Dalian CHN 2697000
|
||||
1903 Qingdao CHN 2596000
|
||||
1904 Jinan CHN 2278100
|
||||
1905 Hangzhou CHN 2190500
|
||||
1906 Zhengzhou CHN 2107200
|
||||
1907 Shijiazhuang CHN 2041500
|
||||
1908 Taiyuan CHN 1968400
|
||||
1909 Kunming CHN 1829500
|
||||
1910 Changsha CHN 1809800
|
||||
1911 Nanchang CHN 1691600
|
||||
1912 Fuzhou CHN 1593800
|
||||
1913 Lanzhou CHN 1565800
|
||||
3793 New York USA 8008278
|
||||
3794 Los Angeles USA 3694820
|
||||
3795 Chicago USA 2896016
|
||||
3796 Houston USA 1953631
|
||||
3797 Philadelphia USA 1517550
|
||||
3798 Phoenix USA 1321045
|
||||
3799 San Diego USA 1223400
|
||||
3800 Dallas USA 1188580
|
||||
3801 San Antonio USA 1144646
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
ID Name Country Population
|
||||
1890 Shanghai CHN 9696300
|
||||
1891 Peking CHN 7472000
|
||||
1892 Chongqing CHN 6351600
|
||||
1893 Tianjin CHN 5286800
|
||||
1894 Wuhan CHN 4344600
|
||||
1895 Harbin CHN 4289800
|
||||
1896 Shenyang CHN 4265200
|
||||
1897 Kanton [Guangzhou] CHN 4256300
|
||||
1898 Chengdu CHN 3361500
|
||||
1899 Nanking [Nanjing] CHN 2870300
|
||||
1900 Changchun CHN 2812000
|
||||
1901 Xi´an CHN 2761400
|
||||
1902 Dalian CHN 2697000
|
||||
1903 Qingdao CHN 2596000
|
||||
1904 Jinan CHN 2278100
|
||||
1905 Hangzhou CHN 2190500
|
||||
1906 Zhengzhou CHN 2107200
|
||||
1907 Shijiazhuang CHN 2041500
|
||||
1908 Taiyuan CHN 1968400
|
||||
1909 Kunming CHN 1829500
|
||||
1910 Changsha CHN 1809800
|
||||
1911 Nanchang CHN 1691600
|
||||
1912 Fuzhou CHN 1593800
|
||||
1913 Lanzhou CHN 1565800
|
||||
3793 New York USA 8008278
|
||||
3794 Los Angeles USA 3694820
|
||||
3795 Chicago USA 2896016
|
||||
3796 Houston USA 1953631
|
||||
3797 Philadelphia USA 1517550
|
||||
3798 Phoenix USA 1321045
|
||||
3799 San Diego USA 1223400
|
||||
3800 Dallas USA 1188580
|
||||
3801 San Antonio USA 1144646
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1892 Chongqing CHN 6351600
|
||||
1898 Chengdu CHN 3361500
|
||||
1900 Changchun CHN 2812000
|
||||
1910 Changsha CHN 1809800
|
||||
3795 Chicago USA 2896016
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1892 Chongqing CHN 6351600
|
||||
1898 Chengdu CHN 3361500
|
||||
1900 Changchun CHN 2812000
|
||||
1910 Changsha CHN 1809800
|
||||
3795 Chicago USA 2896016
|
||||
EXPLAIN
|
||||
SELECT * FROM City, Country
|
||||
WHERE City.Name LIKE 'C%' AND City.Population > 1000000 AND
|
||||
@ -1041,3 +973,4 @@ f1 f4 f5
|
||||
998 a 0
|
||||
DROP TABLE t1;
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
SET SESSION optimizer_switch='rowid_filter=default';
|
||||
|
@ -33,6 +33,7 @@ ANALYZE TABLE City;
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
SET SESSION optimizer_switch='rowid_filter=off';
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
|
||||
SELECT COUNT(*) FROM City;
|
||||
@ -117,6 +118,7 @@ SELECT COUNT(*) FROM City WHERE Population > 1000000;
|
||||
SELECT COUNT(*) FROM City WHERE Population > 500000;
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'C%';
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'B%';
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'J%';
|
||||
|
||||
|
||||
# The pattern of the WHERE condition used in the following 3 queries is
|
||||
@ -134,7 +136,7 @@ SELECT * FROM City
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
|
||||
--replace_column 7 # 9 #
|
||||
--replace_result Population,Country,Name Population,Name,Country
|
||||
@ -156,11 +158,11 @@ SELECT * FROM City
|
||||
|
||||
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
|
||||
|
||||
SELECT * FROM City USE INDEX ()
|
||||
@ -207,7 +209,7 @@ SELECT * FROM City
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
@ -241,10 +243,10 @@ SELECT * FROM City
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
|
||||
|
||||
SELECT * FROM City USE INDEX ()
|
||||
@ -293,7 +295,7 @@ SELECT * FROM City WHERE
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
@ -304,7 +306,7 @@ SELECT * FROM City
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
|
||||
--replace_column 9 #
|
||||
--replace_result PRIMARY,Country,Population PRIMARY,Population,Country 4,7,4 4,4,7
|
||||
@ -326,7 +328,7 @@ SELECT * FROM City WHERE
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'J%';
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
@ -334,7 +336,7 @@ SELECT * FROM City
|
||||
|
||||
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
@ -371,12 +373,12 @@ SELECT * FROM City
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
|
||||
|
||||
# Check that the previous 3 plans return the right results when executed
|
||||
@ -390,18 +392,18 @@ SELECT * FROM City
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
|
||||
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
|
||||
|
||||
#
|
||||
@ -459,3 +461,4 @@ WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
|
||||
DROP TABLE t1;
|
||||
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
SET SESSION optimizer_switch='rowid_filter=default';
|
||||
|
@ -1,4 +1,9 @@
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4;
|
||||
DROP DATABASE IF EXISTS world;
|
||||
set names utf8;
|
||||
@ -39,6 +44,7 @@ SELECT COUNT(*) FROM CountryLanguage;
|
||||
COUNT(*)
|
||||
984
|
||||
CREATE INDEX Name ON City(Name);
|
||||
SET SESSION optimizer_switch='rowid_filter=off';
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
SELECT COUNT(*) FROM City;
|
||||
COUNT(*)
|
||||
@ -80,7 +86,7 @@ EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name LIKE 'M%' AND Population > 7000000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
|
||||
1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name LIKE 'C%' AND Population > 1000000;
|
||||
ID Name Country Population
|
||||
@ -335,8 +341,8 @@ ID Name Country Population
|
||||
SELECT * FROM City
|
||||
WHERE Name LIKE 'M%' AND Population > 7000000;
|
||||
ID Name Country Population
|
||||
1024 Mumbai (Bombay) IND 10500000
|
||||
3580 Moscow RUS 8389200
|
||||
1024 Mumbai (Bombay) IND 10500000
|
||||
SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N';
|
||||
COUNT(*)
|
||||
301
|
||||
@ -358,16 +364,19 @@ COUNT(*)
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'B%';
|
||||
COUNT(*)
|
||||
339
|
||||
SELECT COUNT(*) FROM City WHERE Country LIKE 'J%';
|
||||
COUNT(*)
|
||||
256
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
|
||||
@ -384,15 +393,13 @@ ID Name Country Population
|
||||
1810 Montréal CAN 1016376
|
||||
2259 Medellín COL 1861265
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
@ -466,9 +473,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,7,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,7,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
|
||||
@ -479,7 +486,7 @@ SELECT * FROM City
|
||||
WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000
|
||||
AND Country BETWEEN 'S' AND 'Z';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,7,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population 4,4 NULL # Using sort_intersect(PRIMARY,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
@ -495,33 +502,11 @@ WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
554 Santiago de Chile CHL 4703954
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
|
||||
ID Name Country Population
|
||||
@ -727,19 +712,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
|
||||
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name Name,Population,Country 35,4,3 NULL # Using sort_intersect(Name,Population,Country); Using where
|
||||
1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,7,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
@ -779,10 +764,9 @@ ID Name Country Population
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'J%';
|
||||
ID Name Country Population
|
||||
217 Guarulhos BRA 1095874
|
||||
218 Goiânia BRA 1056330
|
||||
1541 Hiroshima JPN 1119117
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
@ -795,19 +779,8 @@ ID Name Country Population
|
||||
1937 Huainan CHN 700000
|
||||
1950 Hegang CHN 520000
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1 Kabul AFG 1780000
|
||||
56 Luanda AGO 2022000
|
||||
69 Buenos Aires ARG 2982146
|
||||
70 La Matanza ARG 1266461
|
||||
71 Córdoba ARG 1157507
|
||||
126 Yerevan ARM 1248700
|
||||
130 Sydney AUS 3276207
|
||||
131 Melbourne AUS 2865329
|
||||
132 Brisbane AUS 1291117
|
||||
133 Perth AUS 1096829
|
||||
144 Baku AZE 1787800
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
|
||||
AND Country BETWEEN 'S' AND 'Z';
|
||||
@ -889,12 +862,12 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL # Using sort_intersect(CountryName,Population); Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
@ -932,73 +905,37 @@ ID Name Country Population
|
||||
2698 Maputo MOZ 1018938
|
||||
2710 Rangoon (Yangon) MMR 3361700
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
ID Name Country Population
|
||||
1890 Shanghai CHN 9696300
|
||||
1891 Peking CHN 7472000
|
||||
1892 Chongqing CHN 6351600
|
||||
1893 Tianjin CHN 5286800
|
||||
1894 Wuhan CHN 4344600
|
||||
1895 Harbin CHN 4289800
|
||||
1896 Shenyang CHN 4265200
|
||||
1897 Kanton [Guangzhou] CHN 4256300
|
||||
1898 Chengdu CHN 3361500
|
||||
1899 Nanking [Nanjing] CHN 2870300
|
||||
1900 Changchun CHN 2812000
|
||||
1901 Xi´an CHN 2761400
|
||||
1902 Dalian CHN 2697000
|
||||
1903 Qingdao CHN 2596000
|
||||
1904 Jinan CHN 2278100
|
||||
1905 Hangzhou CHN 2190500
|
||||
1906 Zhengzhou CHN 2107200
|
||||
1907 Shijiazhuang CHN 2041500
|
||||
1908 Taiyuan CHN 1968400
|
||||
1909 Kunming CHN 1829500
|
||||
1910 Changsha CHN 1809800
|
||||
1911 Nanchang CHN 1691600
|
||||
1912 Fuzhou CHN 1593800
|
||||
1913 Lanzhou CHN 1565800
|
||||
3793 New York USA 8008278
|
||||
3794 Los Angeles USA 3694820
|
||||
3795 Chicago USA 2896016
|
||||
3796 Houston USA 1953631
|
||||
3797 Philadelphia USA 1517550
|
||||
3798 Phoenix USA 1321045
|
||||
3799 San Diego USA 1223400
|
||||
3800 Dallas USA 1188580
|
||||
3801 San Antonio USA 1144646
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000;
|
||||
WHERE Country='USA' AND Population > 1000000;
|
||||
ID Name Country Population
|
||||
1890 Shanghai CHN 9696300
|
||||
1891 Peking CHN 7472000
|
||||
1892 Chongqing CHN 6351600
|
||||
1893 Tianjin CHN 5286800
|
||||
1894 Wuhan CHN 4344600
|
||||
1895 Harbin CHN 4289800
|
||||
1896 Shenyang CHN 4265200
|
||||
1897 Kanton [Guangzhou] CHN 4256300
|
||||
1898 Chengdu CHN 3361500
|
||||
1899 Nanking [Nanjing] CHN 2870300
|
||||
1900 Changchun CHN 2812000
|
||||
1901 Xi´an CHN 2761400
|
||||
1902 Dalian CHN 2697000
|
||||
1903 Qingdao CHN 2596000
|
||||
1904 Jinan CHN 2278100
|
||||
1905 Hangzhou CHN 2190500
|
||||
1906 Zhengzhou CHN 2107200
|
||||
1907 Shijiazhuang CHN 2041500
|
||||
1908 Taiyuan CHN 1968400
|
||||
1909 Kunming CHN 1829500
|
||||
1910 Changsha CHN 1809800
|
||||
1911 Nanchang CHN 1691600
|
||||
1912 Fuzhou CHN 1593800
|
||||
1913 Lanzhou CHN 1565800
|
||||
3793 New York USA 8008278
|
||||
3794 Los Angeles USA 3694820
|
||||
3795 Chicago USA 2896016
|
||||
3796 Houston USA 1953631
|
||||
3797 Philadelphia USA 1517550
|
||||
3798 Phoenix USA 1321045
|
||||
3799 San Diego USA 1223400
|
||||
3800 Dallas USA 1188580
|
||||
3801 San Antonio USA 1144646
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1892 Chongqing CHN 6351600
|
||||
1898 Chengdu CHN 3361500
|
||||
1900 Changchun CHN 2812000
|
||||
1910 Changsha CHN 1809800
|
||||
3795 Chicago USA 2896016
|
||||
SELECT * FROM City
|
||||
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
WHERE Country='USA' AND Population > 1500000 AND Name LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1892 Chongqing CHN 6351600
|
||||
1898 Chengdu CHN 3361500
|
||||
1900 Changchun CHN 2812000
|
||||
1910 Changsha CHN 1809800
|
||||
3795 Chicago USA 2896016
|
||||
EXPLAIN
|
||||
SELECT * FROM City, Country
|
||||
WHERE City.Name LIKE 'C%' AND City.Population > 1000000 AND
|
||||
@ -1042,4 +979,8 @@ f1 f4 f5
|
||||
998 a 0
|
||||
DROP TABLE t1;
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
SET SESSION optimizer_switch='rowid_filter=default';
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
@ -2,6 +2,15 @@
|
||||
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
--source index_intersect.test
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
@ -1,5 +1,6 @@
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
#---------------- Index merge test 2 -------------------------------------------
|
||||
SET SESSION STORAGE_ENGINE = InnoDB;
|
||||
drop table if exists t1,t2;
|
||||
|
@ -20,6 +20,7 @@ let $merge_table_support= 0;
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
|
||||
# The first two tests are disabled because of non deterministic explain output.
|
||||
# If include/index_merge1.inc can be enabled for InnoDB and all other
|
||||
|
@ -1,4 +1,5 @@
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
#---------------- Index merge test 1 -------------------------------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
@ -19,27 +20,26 @@ update t0 set key2=key1,key3=key1,key4=key1,key5=key1,key6=key1,key7=key1,key8=1
|
||||
analyze table t0;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t0 analyze status OK
|
||||
explain select * from t0 where key1 < 3 or key1 > 1020;
|
||||
explain select * from t0 where key1 < 3 or key1 > 920 and key1 < 924;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 range i1 i1 4 NULL 78 Using index condition; Using where
|
||||
1 SIMPLE t0 range i1 i1 4 NULL 5 Using index condition; Using where
|
||||
explain
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
select * from t0 where key1 < 3 or key2 > 920 and key2 < 924;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 45 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 5 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where key1 < 3 or key2 > 920 and key2 < 924;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
2 2 2 2 2 2 2 1022
|
||||
1021 1021 1021 1021 1021 1021 1021 3
|
||||
1022 1022 1022 1022 1022 1022 1022 2
|
||||
1023 1023 1023 1023 1023 1023 1023 1
|
||||
1024 1024 1024 1024 1024 1024 1024 0
|
||||
921 921 921 921 921 921 921 103
|
||||
922 922 922 922 922 922 922 102
|
||||
923 923 923 923 923 923 923 101
|
||||
select * from t0 where key1=1022;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1022 1022 1022 1022 1022 1022 1022 2
|
||||
explain select * from t0 where key1 < 3 or key2 <4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 5 Using sort_union(i1,i2); Using where
|
||||
explain
|
||||
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -63,7 +63,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ref i1,i2,i3 i3 4 const 1 Using where
|
||||
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <4) and key3 = 50;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 5 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where (key1 > 1 or key2 > 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where
|
||||
@ -74,7 +74,7 @@ explain
|
||||
select * from t0 where key1<3 or key2<3 or (key1>5 and key1<8) or
|
||||
(key1>10 and key1<12) or (key2>100 and key2<110);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 17 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 15 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where key2 = 45 or key1 <=> null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 range i1,i2 i2 4 NULL 1 Using index condition
|
||||
@ -93,19 +93,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or
|
||||
(key3=10) or (key4 <=> null);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4 i2,i3 4,4 NULL 6 Using sort_union(i2,i3); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4 i2,i3 4,4 NULL 5 Using sort_union(i2,i3); Using where
|
||||
explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
|
||||
(key3=10) or (key4 <=> null);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 6 Using sort_union(i1,i3); Using where
|
||||
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 5 Using sort_union(i1,i3); Using where
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
|
||||
explain
|
||||
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 9 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
@ -116,15 +116,15 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i5,i6 4,4 NULL 2 Using sort_union(i5,i6); Using where
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 100);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 1000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
|
||||
or
|
||||
@ -136,7 +136,7 @@ explain select * from t0 where
|
||||
or
|
||||
key1 < 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
|
||||
or
|
||||
@ -148,30 +148,36 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
||||
4 4 4 4 4 4 4 1020
|
||||
5 5 5 5 5 5 5 1019
|
||||
6 6 6 6 6 6 6 1018
|
||||
select count(*) from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
|
||||
or
|
||||
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
|
||||
count(*)
|
||||
5
|
||||
explain select * from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
|
||||
or
|
||||
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL 19 Using sort_union(i1,i2,i5,i6); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL 15 Using sort_union(i1,i2,i5,i6); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
((key7 <7 or key8 < 4) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 20 Using sort_union(i3,i5,i7,i8); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 16 Using sort_union(i3,i5,i7,i8); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
((key3 <7 or key5 < 2) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL 11 Using sort_union(i3,i5); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL 9 Using sort_union(i3,i5); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
(((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL 11 Using sort_union(i3,i5); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL 9 Using sort_union(i3,i5); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
@ -197,7 +203,7 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
||||
explain
|
||||
select * from t0 where key1 < 5 or key8 < 4 order by key1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i8 i1,i8 4,4 NULL 9 Using sort_union(i1,i8); Using where; Using filesort
|
||||
1 SIMPLE t0 index_merge i1,i8 i1,i8 4,4 NULL 7 Using sort_union(i1,i8); Using where; Using filesort
|
||||
create table t2 like t0;
|
||||
insert into t2 select * from t0;
|
||||
alter table t2 add index i1_3(key1, key3);
|
||||
@ -213,7 +219,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index i1_3,i2_3 i321 12 NULL 1024 Using where; Using index
|
||||
explain select key7 from t2 where key1 <100 or key2 < 100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 188 Using sort_union(i1_3,i2_3); Using where
|
||||
1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 186 Using sort_union(i1_3,i2_3); Using where
|
||||
create table t4 (
|
||||
key1a int not null,
|
||||
key1b int not null,
|
||||
@ -238,10 +244,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 index_merge i1a,i1b i1a,i1b 4,4 NULL 2 Using sort_union(i1a,i1b); Using where
|
||||
explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 10 Using where
|
||||
1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 9 Using where
|
||||
explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 10 Using where
|
||||
1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 9 Using where
|
||||
explain select * from t4 where key2_1 = 1 or key2_2 = 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 1024 Using where
|
||||
@ -282,13 +288,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select * from t0,t1 where t0.key1 < 3 and
|
||||
(t1.key1 = t0.key1 or t1.key8 = t0.key1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 range i1 i1 4 NULL 3 Using index condition
|
||||
1 SIMPLE t0 range i1 i1 4 NULL 2 Using index condition
|
||||
1 SIMPLE t1 ALL i1,i8 NULL NULL NULL 1024 Range checked for each record (index map: 0x81)
|
||||
explain select * from t1 where key1=3 or key2=4
|
||||
union select * from t1 where key1<4 or key3=5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
2 UNION t1 index_merge i1,i3 i1,i3 4,4 NULL 5 Using sort_union(i1,i3); Using where
|
||||
2 UNION t1 index_merge i1,i3 i1,i3 4,4 NULL 4 Using sort_union(i1,i3); Using where
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=off,derived_with_keys=off';
|
||||
@ -329,7 +335,7 @@ key1 key2 key3 key4 key5 key6 key7 key8 key9 keyA keyB keyC
|
||||
1016 1016 1016 1016 1016 1016 1016 8 1016 1016 1016 1016
|
||||
explain select * from t0 where key1 < 3 or key2 < 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 5 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where key1 < 3 or key2 < 4;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
@ -357,8 +363,8 @@ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
and (B.key1 < 500000 or B.key2 < 3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1013 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1013 Using sort_union(i1,i2); Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1010 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1010 Using sort_union(i1,i2); Using where; Using join buffer (flat, BNL join)
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
@ -371,8 +377,8 @@ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
and (B.key1 = 1 or B.key2 = 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1020 Using union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1020 Using union(i1,i2); Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1021 Using union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1021 Using union(i1,i2); Using where; Using join buffer (flat, BNL join)
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
@ -517,7 +523,7 @@ a filler b
|
||||
must use union, not sort-union:
|
||||
explain select * from t2 where a=4 or b=4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index_merge a,b a,b 5,5 NULL # Using union(a,b); Using where
|
||||
1 SIMPLE t2 ALL a,b NULL NULL NULL # Using where
|
||||
select * from t2 where a=4 or b=4;
|
||||
a filler b
|
||||
4 4 0
|
||||
@ -705,19 +711,19 @@ select key1,key2,filler1 from t1 where key2=100 and key2=200;
|
||||
key1 key2 filler1
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 152 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 154 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
-1 -1 100 100 key4-key3
|
||||
delete from t1 where key3=100 and key4=100;
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 152 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 154 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
explain select key1,key2 from t1 where key1=100 and key2=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 76 Using intersect(key1,key2); Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 77 Using intersect(key1,key2); Using where; Using index
|
||||
select key1,key2 from t1 where key1=100 and key2=100;
|
||||
key1 key2
|
||||
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
|
||||
@ -725,7 +731,7 @@ insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key
|
||||
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 136 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 137 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
@ -734,7 +740,7 @@ key1 key2 key3 key4 filler1
|
||||
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 146 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 148 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
@ -744,7 +750,7 @@ key1 key2 key3 key4 filler1
|
||||
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 156 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 159 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
@ -760,7 +766,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 3515 Using intersect(st_a,st_b); Using where; Using index
|
||||
explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,stb_swt1a_2b,stb_swt1b,st_b st_b 4 const 15093 Using where
|
||||
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,stb_swt1a_2b,stb_swt1b,st_b st_b 4 const 15094 Using where
|
||||
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt21a 12 const,const,const 971
|
||||
@ -850,7 +856,7 @@ INDEX i2(key2)
|
||||
);
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 5 or key2 > 197;
|
||||
key1 key2
|
||||
0 200
|
||||
@ -860,7 +866,7 @@ key1 key2
|
||||
4 196
|
||||
explain select * from t1 where key1 < 3 or key2 > 195;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 3 or key2 > 195;
|
||||
key1 key2
|
||||
0 200
|
||||
@ -876,7 +882,7 @@ update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if
|
||||
alter table t1 add primary key (str1, zeroval, str2, str3);
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 5 or key2 > 197;
|
||||
key1 key2 str1 zeroval str2 str3
|
||||
0 200 aaa 0 bbb 200-0_a
|
||||
@ -886,7 +892,7 @@ key1 key2 str1 zeroval str2 str3
|
||||
4 196 aaa 0 bbb 196-2_a
|
||||
explain select * from t1 where key1 < 3 or key2 > 195;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 3 or key2 > 195;
|
||||
key1 key2 str1 zeroval str2 str3
|
||||
0 200 aaa 0 bbb 200-0_a
|
||||
@ -1444,7 +1450,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref key1,pktail4bad pktail4bad 4 const 82 Using where
|
||||
explain select * from t1 where pktail5bad=1 and key1=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref key1,pktail5bad pktail5bad 4 const 70 Using where
|
||||
1 SIMPLE t1 ref key1,pktail5bad pktail5bad 4 const 69 Using where
|
||||
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where
|
||||
@ -1498,7 +1504,7 @@ EXPLAIN SELECT t1.f1 FROM t1
|
||||
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
2 SUBQUERY t2 ref f2,f3 f2 5 const 1 Using where
|
||||
2 SUBQUERY t2 ref f2,f3 f2 5 const 2 Using where
|
||||
DROP TABLE t1,t2;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
@ -1515,12 +1521,12 @@ explain select * from t1 where a=1 or b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using union(a,b); Using where
|
||||
This should use ALL:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
|
||||
This should use sort-union:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using sort_union(a,b); Using where
|
||||
@ -1530,17 +1536,17 @@ explain select * from t1 where a<1 or b <1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where
|
||||
This should use ALL:
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
|
||||
This should use ALL:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
|
||||
This will use sort-union:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where
|
||||
@ -1552,7 +1558,7 @@ explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b,c,d a,b 5,5 NULL 3 Using sort_union(a,b); Using where
|
||||
And if we disable sort_union, union:
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b,c,d c,d 5,5 NULL 100 Using union(c,d); Using where
|
||||
@ -1571,22 +1577,22 @@ explain select * from t1 where a=10 and b=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
|
||||
No intersect when index_merge is disabled:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a,b a 5 const 49 Using where
|
||||
No intersect if it is disabled:
|
||||
set optimizer_switch='default,index_merge_sort_intersection=off,index_merge_intersection=off';
|
||||
set optimizer_switch='default,index_merge_sort_intersection=off,index_merge_intersection=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a,b a 5 const 49 Using where
|
||||
Do intersect when union was disabled
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
|
||||
Do intersect when sort_union was disabled
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
|
||||
@ -1596,13 +1602,13 @@ explain select * from t1 where a=10 and b=10 or c=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b,c a,b,c 5,5,5 NULL 6 Using union(intersect(a,b),c); Using where
|
||||
Should be only union left:
|
||||
set optimizer_switch='default,index_merge_intersection=off';
|
||||
set optimizer_switch='default,index_merge_intersection=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10 or c=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using union(a,c); Using where
|
||||
This will switch to sort-union (intersection will be gone, too,
|
||||
that's a known limitation:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10 or c=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using sort_union(a,c); Using where
|
||||
@ -1647,7 +1653,7 @@ SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code )
|
||||
WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL )
|
||||
AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge PRIMARY,code,population_rate,area_rate PRIMARY,population_rate,area_rate 4,5,5 NULL 2 Using sort_union(PRIMARY,population_rate,area_rate); Using where
|
||||
1 SIMPLE t1 index_merge PRIMARY,code,population_rate,area_rate PRIMARY,population_rate,area_rate,code 4,5,5,3 NULL 2 Using sort_union(PRIMARY,population_rate,area_rate,code); Using where
|
||||
SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code )
|
||||
WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL )
|
||||
AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX');
|
||||
|
@ -16,6 +16,7 @@ let $merge_table_support= 1;
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
|
||||
--source include/index_merge1.inc
|
||||
@ -39,11 +40,11 @@ from t0 A, t0 B, t0 C;
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
|
||||
--echo This should use ALL:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
|
||||
--echo This should use sort-union:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
|
||||
--echo This will use sort-union:
|
||||
@ -51,16 +52,16 @@ set optimizer_switch=default;
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
|
||||
--echo This should use ALL:
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
|
||||
|
||||
--echo This should use ALL:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
|
||||
--echo This will use sort-union:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a<1 or b <1;
|
||||
|
||||
alter table t1 add d int, add key(d);
|
||||
@ -71,7 +72,7 @@ set optimizer_switch=default;
|
||||
explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
|
||||
|
||||
--echo And if we disable sort_union, union:
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
|
||||
|
||||
drop table t1;
|
||||
@ -92,19 +93,19 @@ set optimizer_switch=default;
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
|
||||
--echo No intersect when index_merge is disabled:
|
||||
set optimizer_switch='default,index_merge=off';
|
||||
set optimizer_switch='default,index_merge=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
|
||||
--echo No intersect if it is disabled:
|
||||
set optimizer_switch='default,index_merge_sort_intersection=off,index_merge_intersection=off';
|
||||
set optimizer_switch='default,index_merge_sort_intersection=off,index_merge_intersection=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
|
||||
--echo Do intersect when union was disabled
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
|
||||
--echo Do intersect when sort_union was disabled
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
set optimizer_switch='default,index_merge_sort_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10;
|
||||
|
||||
# Now take union-of-intersection and see how we can disable parts of it
|
||||
@ -113,12 +114,12 @@ set optimizer_switch=default;
|
||||
explain select * from t1 where a=10 and b=10 or c=10;
|
||||
|
||||
--echo Should be only union left:
|
||||
set optimizer_switch='default,index_merge_intersection=off';
|
||||
set optimizer_switch='default,index_merge_intersection=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10 or c=10;
|
||||
|
||||
--echo This will switch to sort-union (intersection will be gone, too,
|
||||
--echo that's a known limitation:
|
||||
set optimizer_switch='default,index_merge_union=off';
|
||||
set optimizer_switch='default,index_merge_union=off,rowid_filter=off';
|
||||
explain select * from t1 where a=10 and b=10 or c=10;
|
||||
|
||||
set optimizer_switch=default;
|
||||
|
@ -1,6 +1,11 @@
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4;
|
||||
DROP DATABASE IF EXISTS dbt3_s001;
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
CREATE DATABASE dbt3_s001;
|
||||
use dbt3_s001;
|
||||
set @save_ext_key_optimizer_switch=@@optimizer_switch;
|
||||
@ -1027,10 +1032,14 @@ create table t1 (a bigint not null unique auto_increment, b varchar(10), primary
|
||||
create table t2 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = innodb default character set utf8;
|
||||
insert into t1 (b) values (null), (null), (null);
|
||||
insert into t2 (b) values (null), (null), (null);
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
set optimizer_switch='extended_keys=on';
|
||||
explain select a from t1 where b is null order by a desc limit 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index b PRIMARY 8 NULL 3 Using where
|
||||
1 SIMPLE t1 index b PRIMARY 8 NULL 2 Using where
|
||||
select a from t1 where b is null order by a desc limit 2;
|
||||
a
|
||||
3
|
||||
@ -1208,3 +1217,6 @@ EXPLAIN
|
||||
}
|
||||
}
|
||||
drop table t1;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -7,6 +7,13 @@ DROP DATABASE IF EXISTS dbt3_s001;
|
||||
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
CREATE DATABASE dbt3_s001;
|
||||
|
||||
use dbt3_s001;
|
||||
@ -674,6 +681,8 @@ create table t2 (a bigint not null unique auto_increment, b varchar(10), primary
|
||||
insert into t1 (b) values (null), (null), (null);
|
||||
insert into t2 (b) values (null), (null), (null);
|
||||
|
||||
analyze table t1,t2;
|
||||
|
||||
set optimizer_switch='extended_keys=on';
|
||||
explain select a from t1 where b is null order by a desc limit 2;
|
||||
select a from t1 where b is null order by a desc limit 2;
|
||||
@ -821,3 +830,7 @@ INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def');
|
||||
explain format= json
|
||||
select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3';
|
||||
drop table t1;
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -1,5 +1,10 @@
|
||||
set @save_storage_engine= @@storage_engine;
|
||||
set storage_engine=InnoDB;
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
set @innodb_icp_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
#
|
||||
@ -590,6 +595,10 @@ i1 INTEGER NOT NULL,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO t2 VALUES (4,1);
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
|
||||
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
|
||||
@ -679,7 +688,7 @@ EXPLAIN
|
||||
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
|
||||
HAVING t1.c != 5 ORDER BY t1.c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
|
||||
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
|
||||
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
|
||||
HAVING t1.c != 5 ORDER BY t1.c;
|
||||
@ -690,7 +699,7 @@ EXPLAIN
|
||||
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
|
||||
HAVING t1.c != 5 ORDER BY t1.c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
|
||||
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
|
||||
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
|
||||
HAVING t1.c != 5 ORDER BY t1.c;
|
||||
@ -795,6 +804,10 @@ INSERT INTO t2 (g,h) VALUES
|
||||
(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
|
||||
(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
|
||||
(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u');
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
SET @save_optimize_switch=@@optimizer_switch;
|
||||
SET optimizer_switch='materialization=on';
|
||||
EXPLAIN
|
||||
@ -947,3 +960,6 @@ pk key1 key2
|
||||
drop table t1, t2;
|
||||
set optimizer_switch=@innodb_icp_tmp;
|
||||
set storage_engine= @save_storage_engine;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -7,6 +7,13 @@
|
||||
set @save_storage_engine= @@storage_engine;
|
||||
set storage_engine=InnoDB;
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
set @innodb_icp_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
|
||||
@ -76,3 +83,7 @@ drop table t1, t2;
|
||||
set optimizer_switch=@innodb_icp_tmp;
|
||||
set storage_engine= @save_storage_engine;
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
||||
|
@ -329,6 +329,9 @@ insert into t1 values(1,1,1);
|
||||
insert into t1 values(2,2,2);
|
||||
insert into t1 values(3,3,3);
|
||||
insert into t1 values(4,4,4);
|
||||
insert into t1 values(5,5,5);
|
||||
insert into t1 values(6,6,6);
|
||||
insert into t1 values(7,7,7);
|
||||
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
|
||||
select invisible, a ,b from t1 order by b;
|
||||
invisible a b
|
||||
@ -336,9 +339,12 @@ invisible a b
|
||||
9 2 2
|
||||
9 3 3
|
||||
9 4 4
|
||||
9 5 5
|
||||
9 6 6
|
||||
9 7 7
|
||||
explain select * from t1 where invisible =9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref invisible invisible 5 const 3
|
||||
1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where
|
||||
alter table t1 add x int default 3;
|
||||
select invisible, a ,b from t1;
|
||||
invisible a b
|
||||
@ -346,6 +352,9 @@ invisible a b
|
||||
9 2 2
|
||||
9 3 3
|
||||
9 4 4
|
||||
9 5 5
|
||||
9 6 6
|
||||
9 7 7
|
||||
set debug_dbug=@old_debug;
|
||||
Show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
@ -357,11 +366,11 @@ drop index invisible on t1;
|
||||
ERROR 42000: Can't DROP INDEX `invisible`; check that it exists
|
||||
explain select * from t1 where invisible =9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref invisible invisible 5 const 3
|
||||
1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where
|
||||
create index invisible on t1(c);
|
||||
explain select * from t1 where invisible =9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref invisible_2 invisible_2 5 const 3
|
||||
1 SIMPLE t1 ALL invisible_2 NULL NULL NULL 7 Using where
|
||||
show indexes in t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
|
@ -249,6 +249,9 @@ insert into t1 values(1,1,1);
|
||||
insert into t1 values(2,2,2);
|
||||
insert into t1 values(3,3,3);
|
||||
insert into t1 values(4,4,4);
|
||||
insert into t1 values(5,5,5);
|
||||
insert into t1 values(6,6,6);
|
||||
insert into t1 values(7,7,7);
|
||||
set debug_dbug= "+d,test_completely_invisible,test_invisible_index";
|
||||
select invisible, a ,b from t1 order by b;
|
||||
explain select * from t1 where invisible =9;
|
||||
|
@ -1268,6 +1268,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
INSERT INTO t1 VALUES (3,'b'),(4,NULL),(5,'c'),(6,'cc'),(7,'d'),
|
||||
(8,'dd'),(9,'e'),(10,'ee');
|
||||
INSERT INTO t2 VALUES (2,NULL);
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1;
|
||||
pk v pk v
|
||||
|
@ -955,6 +955,7 @@ EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.v = t2.v;
|
||||
INSERT INTO t1 VALUES (3,'b'),(4,NULL),(5,'c'),(6,'cc'),(7,'d'),
|
||||
(8,'dd'),(9,'e'),(10,'ee');
|
||||
INSERT INTO t2 VALUES (2,NULL);
|
||||
ANALYZE TABLE t1,t2;
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1;
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
|
@ -6,6 +6,11 @@ set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on';
|
||||
set @@optimizer_switch='semijoin_with_cache=on';
|
||||
set @@optimizer_switch='outer_join_with_cache=on';
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
set @local_join_cache_test_optimizer_switch_default=@@optimizer_switch;
|
||||
set names utf8;
|
||||
CREATE DATABASE world;
|
||||
@ -402,7 +407,7 @@ ON City.Country=Country.Code AND City.Population > 5000000
|
||||
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
|
||||
1 SIMPLE City hash_range City_Population #hash#$hj:City_Population 3:4 world.Country.Code 25 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join)
|
||||
1 SIMPLE City hash_range City_Population #hash#$hj:City_Population 3:4 world.Country.Code 24 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join)
|
||||
SELECT Country.Name, Country.Population, City.Name, City.Population
|
||||
FROM Country LEFT JOIN City
|
||||
ON City.Country=Country.Code AND City.Population > 5000000
|
||||
@ -3037,13 +3042,13 @@ t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND
|
||||
t1.metaid = t2.metaid AND t1.affiliateid = '2';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t6 system PRIMARY NULL NULL NULL 1
|
||||
1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 1
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using index
|
||||
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t5 ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1
|
||||
1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t1.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using index
|
||||
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t9 index PRIMARY,t9_subgenreid,t9_metaid PRIMARY 8 NULL 2 Using where; Using index; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t10 eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
@ -3160,7 +3165,7 @@ Warning 1292 Truncated incorrect join_buffer_size value: '32'
|
||||
set join_cache_level=8;
|
||||
EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL idx NULL NULL NULL 7 Using where
|
||||
1 SIMPLE t1 range idx idx 5 NULL 3 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref idx idx 5 test.t1.a 2 Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
|
||||
SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30;
|
||||
a b a b
|
||||
@ -5095,7 +5100,7 @@ SET SESSION join_cache_level = 1;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
1 SIMPLE t2 ref idx idx 5 const 4 Using index condition
|
||||
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
|
||||
a a b
|
||||
@ -5111,7 +5116,7 @@ SET SESSION join_cache_level = 4;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
1 SIMPLE t2 hash_range idx #hash#idx:idx 5:5 const 4 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join)
|
||||
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
|
||||
a a b
|
||||
@ -5414,7 +5419,7 @@ ORDER BY t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where; Using filesort
|
||||
1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where; Using filesort
|
||||
1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND
|
||||
@ -5432,7 +5437,7 @@ ORDER BY t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where
|
||||
1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where
|
||||
1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND
|
||||
@ -5451,7 +5456,7 @@ ORDER BY t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where
|
||||
1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where
|
||||
1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND
|
||||
@ -5934,6 +5939,10 @@ CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES
|
||||
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
|
||||
(228,'x'),(3,'y'),(1,'z'),(9,'z');
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
CREATE TABLE temp
|
||||
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
|
||||
SELECT * FROM temp
|
||||
@ -6050,3 +6059,6 @@ f2
|
||||
drop table t1, t2;
|
||||
set join_buffer_size = default;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -10,6 +10,13 @@ set @@optimizer_switch='semijoin_with_cache=on';
|
||||
set @@optimizer_switch='outer_join_with_cache=on';
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
set @local_join_cache_test_optimizer_switch_default=@@optimizer_switch;
|
||||
set names utf8;
|
||||
|
||||
@ -3886,6 +3893,8 @@ INSERT INTO t2 VALUES
|
||||
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
|
||||
(228,'x'),(3,'y'),(1,'z'),(9,'z');
|
||||
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
CREATE TABLE temp
|
||||
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
|
||||
|
||||
@ -3990,3 +3999,7 @@ set join_buffer_size = default;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -1062,9 +1062,9 @@ t0.b=t1.b AND
|
||||
(t8.b=t9.b OR t8.c IS NULL) AND
|
||||
(t9.a=1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t0 ref idx_a idx_a 5 const 1 100.00 Using where
|
||||
1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00
|
||||
1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 85.71 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where
|
||||
@ -1110,13 +1110,13 @@ t0.b=t1.b AND
|
||||
(t9.a=1);
|
||||
a b a b a b a b a b a b a b a b a b a b
|
||||
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1
|
||||
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2
|
||||
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1
|
||||
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
|
||||
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1
|
||||
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
|
||||
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1
|
||||
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1
|
||||
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2
|
||||
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2
|
||||
1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2
|
||||
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2
|
||||
@ -1209,13 +1209,13 @@ INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5);
|
||||
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
|
||||
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
|
||||
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
|
||||
1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index
|
||||
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
|
||||
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
|
||||
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
|
||||
1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index
|
||||
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
|
||||
a b c
|
||||
NULL 0 0
|
||||
|
@ -1073,9 +1073,9 @@ t0.b=t1.b AND
|
||||
(t8.b=t9.b OR t8.c IS NULL) AND
|
||||
(t9.a=1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t0 ref idx_a idx_a 5 const 1 100.00 Using where
|
||||
1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 ALL idx_b NULL NULL NULL 7 85.71 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
@ -1220,13 +1220,13 @@ INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5);
|
||||
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
|
||||
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
|
||||
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
|
||||
1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index
|
||||
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
|
||||
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
|
||||
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
|
||||
1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index
|
||||
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
|
||||
a b c
|
||||
NULL 0 0
|
||||
@ -2002,8 +2002,8 @@ ON t6.b >= 2 AND t5.b=t7.b AND
|
||||
(t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t7 ref PRIMARY,b_i b_i 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 SIMPLE t6 ALL PRIMARY,b_i NULL NULL NULL 7 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 2 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using filter
|
||||
1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using filter
|
||||
1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
|
||||
FROM t5
|
||||
|
@ -1740,7 +1740,7 @@ from t1,t2
|
||||
where t2.pk=t1.pk+1000 and t1.pk>1000
|
||||
group by t2.pk;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using temporary; Using filesort
|
||||
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index
|
||||
|
@ -1751,7 +1751,7 @@ from t1,t2
|
||||
where t2.pk=t1.pk+1000 and t1.pk>1000
|
||||
group by t2.pk;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using temporary; Using filesort
|
||||
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index
|
||||
|
@ -216,7 +216,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
|
||||
explain select 1 from t1 where id =2 or id=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
explain select name from t1 where id =2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
|
||||
@ -603,11 +603,14 @@ 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);
|
||||
ANALYZE table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 4 Using index for group-by
|
||||
SELECT 1 as RES FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
RES
|
||||
|
@ -555,6 +555,7 @@ 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);
|
||||
ANALYZE table t1;
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
SELECT 1 as RES FROM t1 AS t1_outer WHERE
|
||||
|
@ -440,25 +440,25 @@ VARIABLE_NAME VARIABLE_VALUE
|
||||
KEY_BLOCKS_NOT_FLUSHED 0
|
||||
KEY_BLOCKS_USED 4
|
||||
KEY_BLOCKS_WARM 0
|
||||
KEY_READ_REQUESTS 22
|
||||
KEY_READ_REQUESTS 24
|
||||
KEY_READS 0
|
||||
KEY_WRITE_REQUESTS 26
|
||||
KEY_WRITES 6
|
||||
select variable_value into @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused';
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default NULL NULL 2097152 1024 4 # 0 22 0 26 6
|
||||
default NULL NULL 2097152 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
delete from t2 where a='zzzz';
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default NULL NULL 2097152 1024 4 # 0 29 0 32 9
|
||||
default NULL NULL 2097152 1024 4 # 0 32 0 32 9
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default NULL NULL 2097152 1024 4 # 0 29 0 32 9
|
||||
default NULL NULL 2097152 1024 4 # 0 32 0 32 9
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
set global key_cache_segments=2;
|
||||
select @@key_cache_segments;
|
||||
@ -488,7 +488,7 @@ VARIABLE_NAME VARIABLE_VALUE
|
||||
KEY_BLOCKS_NOT_FLUSHED 0
|
||||
KEY_BLOCKS_USED 4
|
||||
KEY_BLOCKS_WARM 0
|
||||
KEY_READ_REQUESTS 22
|
||||
KEY_READ_REQUESTS 24
|
||||
KEY_READS 0
|
||||
KEY_WRITE_REQUESTS 26
|
||||
KEY_WRITES 6
|
||||
@ -497,13 +497,13 @@ variable_value < @key_blocks_unused
|
||||
1
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 2097152 1024 4 # 0 22 0 26 6
|
||||
default 2 NULL 2097152 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 2097152 1024 4 # 0 22 0 26 6
|
||||
default 2 NULL 2097152 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
set global key_cache_segments=1;
|
||||
select @@key_cache_segments;
|
||||
@ -533,7 +533,7 @@ VARIABLE_NAME VARIABLE_VALUE
|
||||
KEY_BLOCKS_NOT_FLUSHED 0
|
||||
KEY_BLOCKS_USED 4
|
||||
KEY_BLOCKS_WARM 0
|
||||
KEY_READ_REQUESTS 22
|
||||
KEY_READ_REQUESTS 24
|
||||
KEY_READS 0
|
||||
KEY_WRITE_REQUESTS 26
|
||||
KEY_WRITES 6
|
||||
@ -542,13 +542,13 @@ variable_value = @key_blocks_unused
|
||||
1
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 1 NULL 2097152 1024 4 # 0 22 0 26 6
|
||||
default 1 NULL 2097152 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 1 NULL 2097152 1024 4 # 0 22 0 26 6
|
||||
default 1 NULL 2097152 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 1 0 2 1
|
||||
flush tables;
|
||||
flush status;
|
||||
@ -586,7 +586,7 @@ update t1 set p=3 where p=1;
|
||||
update t2 set i=2 where i=1;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 4 # 0 22 0 26 6
|
||||
default 2 NULL 32768 1024 4 # 0 24 0 26 6
|
||||
small NULL NULL 1048576 1024 1 # 0 0 0 0 0
|
||||
insert into t1(a) select a from t1;
|
||||
insert into t1(a) select a from t1;
|
||||
@ -606,7 +606,7 @@ insert into t2(i,a) select i,a from t2;
|
||||
insert into t2(i,a) select i,a from t2;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 6733 # 3684 103
|
||||
default 2 NULL 32768 1024 # # 0 6735 # 3684 103
|
||||
small NULL NULL 1048576 1024 # # 0 0 # 0 0
|
||||
select * from t1 where p between 1010 and 1020 ;
|
||||
p a
|
||||
@ -625,7 +625,7 @@ p i a
|
||||
1020 3 zzzz
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 6750 # 3684 103
|
||||
default 2 NULL 32768 1024 # # 0 6756 # 3684 103
|
||||
small NULL NULL 1048576 1024 # # 0 0 # 0 0
|
||||
flush tables;
|
||||
flush status;
|
||||
@ -633,7 +633,7 @@ update t1 set a='zzzz' where a='qqqq';
|
||||
update t2 set i=1 where i=2;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3076 18 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3078 18 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
set global keycache1.key_buffer_size=256*1024;
|
||||
select @@keycache1.key_buffer_size;
|
||||
@ -645,7 +645,7 @@ select @@keycache1.key_cache_segments;
|
||||
7
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3076 18 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3078 18 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 0 0 0 0
|
||||
select * from information_schema.key_caches where key_cache_name like "key%"
|
||||
@ -662,7 +662,7 @@ select p from t1 where p between 1010 and 1020;
|
||||
p
|
||||
explain select i from t2 where p between 1010 and 1020;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 28 Using index condition
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 9 Using index condition
|
||||
select i from t2 where p between 1010 and 1020;
|
||||
i
|
||||
1
|
||||
@ -685,13 +685,13 @@ count(*)
|
||||
256
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 14 3 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 18 3 0 0
|
||||
select * from information_schema.key_caches where key_cache_name like "key%"
|
||||
and segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
keycache1 7 NULL 262143 2048 3 # 0 14 3 0 0
|
||||
keycache1 7 NULL 262143 2048 3 # 0 18 3 0 0
|
||||
cache index t2 in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 assign_to_keycache status OK
|
||||
@ -699,7 +699,7 @@ update t2 set p=p+3000, i=2 where a='qqqq';
|
||||
select * from information_schema.key_caches where key_cache_name like "key%"
|
||||
and segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
|
||||
keycache1 7 NULL 262143 2048 25 # 0 2088 25 1071 19
|
||||
set global keycache2.key_buffer_size=1024*1024;
|
||||
cache index t2 in keycache2;
|
||||
Table Op Msg_type Msg_text
|
||||
@ -712,7 +712,7 @@ keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
|
||||
select * from information_schema.key_caches where key_cache_name like "key%"
|
||||
and segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
|
||||
keycache1 7 NULL 262143 2048 25 # 0 2088 25 1071 19
|
||||
keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
|
||||
cache index t2 in keycache1;
|
||||
Table Op Msg_type Msg_text
|
||||
@ -728,7 +728,7 @@ p i a
|
||||
1019 1 yyyy
|
||||
explain select p from t2 where p between 1010 and 1020;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
|
||||
select p from t2 where p between 1010 and 1020;
|
||||
p
|
||||
1010
|
||||
@ -739,92 +739,92 @@ p
|
||||
1019
|
||||
explain select i from t2 where a='yyyy' and i=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref k1,k2 k1 5 const 188 Using where
|
||||
1 SIMPLE t2 ref|filter k1,k2 k1|k2 5|11 const 189 (27%) Using where; Using filter
|
||||
select i from t2 where a='yyyy' and i=3;
|
||||
i
|
||||
3
|
||||
explain select a from t2 where a='yyyy' and i=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref k1,k2 k1 5 const 188 Using where
|
||||
1 SIMPLE t2 ref|filter k1,k2 k1|k2 5|11 const 189 (27%) Using where; Using filter
|
||||
select a from t2 where a='yyyy' and i=3 ;
|
||||
a
|
||||
yyyy
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 3201 43 1594 30
|
||||
keycache1 7 NULL 262143 2048 # # 0 3283 43 1594 30
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=2*1024;
|
||||
insert into t2 values (7000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 262143 2048 # # 0 6 6 3 3
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 262143 8192 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
insert into t2 values (8000, 3, 'yyyy');
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 262143 8192 # # 0 6 5 3 3
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=64*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=2*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 3 NULL 65535 2048 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=8*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=0;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_buffer_size=128*1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 1 NULL 131072 8192 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
set global keycache1.key_cache_block_size=1024;
|
||||
select * from information_schema.key_caches where segment_number is null;
|
||||
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
|
||||
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
|
||||
default 2 NULL 32768 1024 # # 0 3178 24 1552 18
|
||||
small NULL NULL 1048576 1024 # # 0 0 0 0 0
|
||||
keycache1 7 NULL 131068 1024 # # 0 0 0 0 0
|
||||
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
|
||||
|
@ -76,21 +76,21 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY p7 ALL NULL NULL NULL NULL 50 Using where; Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY p8 ALL NULL NULL NULL NULL 50 Using where; Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY p9 ALL NULL NULL NULL NULL 50 Using where; Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived4> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived5> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived6> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived7> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived8> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived9> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived10> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived11> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived12> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived13> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived14> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived15> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived16> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived17> ALL NULL NULL NULL NULL -1127208515966861312 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived5> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived7> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived8> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived9> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived10> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived11> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived12> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived13> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived14> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived15> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived16> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <derived17> ALL NULL NULL NULL NULL 17319535557742690304 Using join buffer (incremental, BNL join)
|
||||
17 DERIVED r1 ALL NULL NULL NULL NULL 2
|
||||
17 DERIVED d1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
17 DERIVED r2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
|
||||
|
@ -38,7 +38,7 @@ insert into t1 select NULL,message from t2;
|
||||
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2);
|
||||
explain select * from t3 where a < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range a a 4 NULL 18 Using where
|
||||
1 SIMPLE t3 range a a 4 NULL 17 Using where
|
||||
explain select * from t3 where a > 10 and a < 20;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range a a 4 NULL 17 Using where
|
||||
@ -669,15 +669,15 @@ KEY files (fileset_id,fileset_root_id)
|
||||
EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
|
||||
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 35 NULL 5 Using where
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 35 NULL 6 Using where
|
||||
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
||||
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range PRIMARY,files PRIMARY 35 NULL 5 Using where
|
||||
1 SIMPLE t2 range PRIMARY,files PRIMARY 35 NULL 6 Using where
|
||||
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
|
||||
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY,files PRIMARY 35 NULL 5 Using index condition
|
||||
1 SIMPLE t1 range PRIMARY,files PRIMARY 35 NULL 6 Using index condition
|
||||
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
||||
AND file_code = '0000000115' LIMIT 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -742,7 +742,7 @@ insert into t1 (a,b,c) values (1,1,0),(1,2,0);
|
||||
insert into t2 (a,b,c) values (1,1,1),(1,2,1);
|
||||
explain select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
||||
1 SIMPLE t3 ref a a 5 const 4 Using where; Using index
|
||||
select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
||||
a b c
|
||||
1 1 0
|
||||
@ -751,7 +751,7 @@ a b c
|
||||
1 2 1
|
||||
explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
||||
1 SIMPLE t3 ref a a 5 const 4 Using where; Using index
|
||||
select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
||||
a b c
|
||||
1 2 1
|
||||
|
@ -1,6 +1,7 @@
|
||||
call mtr.add_suppression("Can't find record in .*");
|
||||
set @mrr_icp_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1
|
||||
(s1 char(10) COLLATE latin1_german1_ci,
|
||||
@ -82,7 +83,7 @@ a b
|
||||
4 NULL
|
||||
explain select * from t1 where b=2 or b is null order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null b b 5 const 3 Using index condition; Using where; Using filesort
|
||||
1 SIMPLE t1 ref_or_null b b 5 const 4 Using index condition; Using where; Using filesort
|
||||
select * from t1 where b=2 or b is null order by a;
|
||||
a b
|
||||
3 NULL
|
||||
@ -103,10 +104,10 @@ KEY StringField (FieldKey,StringVal(32))
|
||||
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
|
||||
EXPLAIN SELECT * FROM t1 IGNORE INDEX (LongField, StringField) WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range FieldKey FieldKey 38 NULL 4 Using index condition; Rowid-ordered scan; Using filesort
|
||||
1 SIMPLE t1 range FieldKey FieldKey 38 NULL 3 Using index condition; Rowid-ordered scan; Using filesort
|
||||
EXPLAIN SELECT * FROM t1 IGNORE INDEX (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range StringField StringField 38 NULL 4 Using where; Using filesort
|
||||
1 SIMPLE t1 range StringField StringField 38 NULL 3 Using where; Using filesort
|
||||
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
FieldKey LongVal StringVal
|
||||
3 1 2
|
||||
@ -124,7 +125,7 @@ Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
explain select * from t1 force index (a) where a=0 or a=2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range a a 4 NULL 5 Using index condition; Using where; Rowid-ordered scan
|
||||
select * from t1 force index (a) where a=0 or a=2;
|
||||
a b c
|
||||
0 NULL 0
|
||||
|
@ -4,6 +4,7 @@ call mtr.add_suppression("Can't find record in .*");
|
||||
|
||||
set @mrr_icp_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1
|
||||
(s1 char(10) COLLATE latin1_german1_ci,
|
||||
|
@ -395,7 +395,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
|
||||
explain select * from t1 force index (a) where a=0 or a=2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Using where
|
||||
1 SIMPLE t1 range a a 4 NULL 5 Using index condition; Using where
|
||||
explain select * from t1 where c=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref c,c_2 c 5 const 1
|
||||
@ -641,7 +641,7 @@ create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
|
||||
insert into t1 values (null,''), (null,'');
|
||||
explain select count(*) from t1 where a is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref idx idx 4 const 1 Using where
|
||||
1 SIMPLE t1 ref idx idx 4 const 2 Using where
|
||||
select count(*) from t1 where a is null;
|
||||
count(*)
|
||||
2
|
||||
|
@ -696,12 +696,12 @@ Warnings:
|
||||
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
||||
EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
FLUSH STATUS;
|
||||
FLUSH TABLES;
|
||||
EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
# Status of EXPLAIN EXTENDED query
|
||||
Variable_name Value
|
||||
FLUSH STATUS;
|
||||
@ -721,9 +721,8 @@ Variable_name Value
|
||||
Handler_read_rnd_next 1
|
||||
# Status of testing query execution:
|
||||
Variable_name Value
|
||||
Handler_read_key 1
|
||||
|
||||
INSERT INTO t1 VALUES (1), (2), (3);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (-1), (-2), (-3);
|
||||
#
|
||||
# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a
|
||||
@ -2351,19 +2350,19 @@ Warnings:
|
||||
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
|
||||
EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using buffer
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using buffer
|
||||
FLUSH STATUS;
|
||||
FLUSH TABLES;
|
||||
EXPLAIN EXTENDED UPDATE t1 SET a=a+10 WHERE a > 34;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using buffer
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using buffer
|
||||
# Status of EXPLAIN EXTENDED query
|
||||
Variable_name Value
|
||||
FLUSH STATUS;
|
||||
FLUSH TABLES;
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > 34;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 34
|
||||
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
|
||||
@ -2627,7 +2626,7 @@ DROP TABLE t1;
|
||||
DROP VIEW v1;
|
||||
#63
|
||||
CREATE TABLE t1 (a INT, PRIMARY KEY(a));
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9);
|
||||
CREATE VIEW v1 (a) AS SELECT a FROM t1;
|
||||
#
|
||||
# query: DELETE FROM v1 WHERE a < 4
|
||||
|
@ -505,7 +505,7 @@ SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
|
||||
WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
|
||||
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
|
||||
SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
|
||||
WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
|
||||
@ -588,6 +588,10 @@ i1 INTEGER NOT NULL,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO t2 VALUES (4,1);
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
|
||||
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
|
||||
@ -793,6 +797,10 @@ INSERT INTO t2 (g,h) VALUES
|
||||
(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
|
||||
(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
|
||||
(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u');
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Table is already up to date
|
||||
SET @save_optimize_switch=@@optimizer_switch;
|
||||
SET optimizer_switch='materialization=on';
|
||||
EXPLAIN
|
||||
@ -913,7 +921,7 @@ SET SESSION optimizer_switch='index_condition_pushdown=off';
|
||||
EXPLAIN
|
||||
SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref idx idx 4 const 1 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t1 ref idx idx 4 const 2 Using where; Using temporary; Using filesort
|
||||
SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a;
|
||||
a MIN(c)
|
||||
5 y
|
||||
@ -921,7 +929,7 @@ SET SESSION optimizer_switch='index_condition_pushdown=on';
|
||||
EXPLAIN
|
||||
SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref idx idx 4 const 1 Using index condition; Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t1 ref idx idx 4 const 2 Using index condition; Using where; Using temporary; Using filesort
|
||||
SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a;
|
||||
a MIN(c)
|
||||
5 y
|
||||
@ -976,7 +984,7 @@ set optimizer_switch='mrr=off';
|
||||
# Must not use ICP:
|
||||
explain select * from t1 where a between 5 and 8 order by a desc, col desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 39 Using where
|
||||
1 SIMPLE t1 range a a 5 NULL 40 Using where
|
||||
set optimizer_switch= @tmp_10000051;
|
||||
# Must not use ICP:
|
||||
explain select * from t1 where a=3 and col > 500 order by a desc, col desc;
|
||||
|
@ -210,7 +210,7 @@ NULL NULL NULL NULL-1
|
||||
explain
|
||||
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 range idx1 idx1 29 NULL 21 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t4 range idx1 idx1 29 NULL 20 Using index condition; Using where; Rowid-ordered scan
|
||||
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
|
||||
a b c filler
|
||||
b-1 NULL c-1 NULL-15
|
||||
@ -575,7 +575,7 @@ insert into t1
|
||||
select A.a+10*B.a+100*C.a+1000*D.a, 123,'filler' from t0 A, t0 B, t0 C, t0 D;
|
||||
explain select sum(b) from t1 where a < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 8 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range a a 5 NULL 9 Using index condition; Rowid-ordered scan
|
||||
# This should show one MRR scan and no re-fills:
|
||||
flush status;
|
||||
select sum(b) from t1 where a < 10;
|
||||
|
@ -135,7 +135,7 @@ EXPALIN number of fields: 10
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
|
||||
EXPALIN JSON number of fields: 1
|
||||
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
|
||||
@ -148,7 +148,7 @@ ANALYZE number of fields: 13
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
|
||||
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
@ -164,7 +164,7 @@ EXPALIN INSERT number of fields: 10
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
|
||||
EXPALIN JSON INSERT number of fields: 1
|
||||
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
|
||||
@ -177,7 +177,7 @@ ANALYZE INSERT number of fields: 13
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
|
||||
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
@ -193,7 +193,7 @@ EXPALIN UPDATE number of fields: 10
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
|
||||
EXPALIN JSON UPDATE number of fields: 1
|
||||
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
|
||||
@ -206,7 +206,7 @@ ANALYZE UPDATE number of fields: 13
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
|
||||
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
@ -222,7 +222,7 @@ EXPALIN DELETE number of fields: 10
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
|
||||
EXPALIN JSON DELETE number of fields: 1
|
||||
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
|
||||
@ -235,7 +235,7 @@ ANALYZE DELETE number of fields: 13
|
||||
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
|
||||
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
|
||||
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
|
||||
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
|
||||
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
|
||||
|
@ -546,6 +546,8 @@ The following specify which files/extra groups are read (specified before remain
|
||||
relay log will be rotated automatically when the size
|
||||
exceeds this value. If 0 at startup, it's set to
|
||||
max_binlog_size
|
||||
--max-rowid-filter-size=#
|
||||
The maximum number of rows that fit in memory
|
||||
--max-seeks-for-key=#
|
||||
Limit assumed max number of seeks when looking up rows
|
||||
based on a key
|
||||
@ -679,7 +681,7 @@ The following specify which files/extra groups are read (specified before remain
|
||||
optimize_join_buffer_size, table_elimination,
|
||||
extended_keys, exists_to_in, orderby_uses_equalities,
|
||||
condition_pushdown_for_derived, split_materialized,
|
||||
condition_pushdown_for_subquery
|
||||
condition_pushdown_for_subquery, rowid_filter
|
||||
--optimizer-use-condition-selectivity=#
|
||||
Controls selectivity of which conditions the optimizer
|
||||
takes into account to calculate cardinality of a partial
|
||||
@ -1509,6 +1511,7 @@ max-long-data-size 16777216
|
||||
max-prepared-stmt-count 16382
|
||||
max-recursive-iterations 18446744073709551615
|
||||
max-relay-log-size 1073741824
|
||||
max-rowid-filter-size 131072
|
||||
max-seeks-for-key 18446744073709551615
|
||||
max-session-mem-used 9223372036854775807
|
||||
max-sort-length 1024
|
||||
@ -1545,7 +1548,7 @@ old-style-user-limits FALSE
|
||||
optimizer-prune-level 1
|
||||
optimizer-search-depth 62
|
||||
optimizer-selectivity-sampling-limit 100
|
||||
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
|
||||
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
|
||||
optimizer-use-condition-selectivity 1
|
||||
performance-schema FALSE
|
||||
performance-schema-accounts-size -1
|
||||
|
@ -4336,11 +4336,12 @@ show create event ee1;
|
||||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||||
ee1 UTC CREATE DEFINER=`root`@`localhost` EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5;
|
||||
Warnings:
|
||||
Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation
|
||||
create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
|
||||
show events;
|
||||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||||
second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
drop database second;
|
||||
create database third;
|
||||
@ -4348,7 +4349,6 @@ use third;
|
||||
show events;
|
||||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||||
third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
drop database third;
|
||||
set time_zone = 'SYSTEM';
|
||||
|
@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
|
||||
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
|
||||
explain select * from t1 where not(not(a));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
|
||||
1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
|
||||
select * from t1 where not(not(a));
|
||||
a
|
||||
1
|
||||
@ -28,7 +28,7 @@ a
|
||||
19
|
||||
explain select * from t1 where not(not(not(a > 10)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where not(not(not(a > 10)));
|
||||
a
|
||||
0
|
||||
@ -44,7 +44,7 @@ a
|
||||
10
|
||||
explain select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 6 Using where; Using index
|
||||
select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||
a
|
||||
5
|
||||
@ -55,7 +55,7 @@ a
|
||||
10
|
||||
explain select * from t1 where not(a = 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index
|
||||
1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
|
||||
select * from t1 where not(a = 10);
|
||||
a
|
||||
0
|
||||
@ -85,7 +85,7 @@ a
|
||||
1
|
||||
explain select * from t1 where not(a < 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
select * from t1 where not(a < 10);
|
||||
a
|
||||
10
|
||||
@ -100,7 +100,7 @@ a
|
||||
19
|
||||
explain select * from t1 where not(a >= 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 9 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
select * from t1 where not(a >= 10);
|
||||
a
|
||||
0
|
||||
@ -115,7 +115,7 @@ a
|
||||
9
|
||||
explain select * from t1 where not(a > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where not(a > 10);
|
||||
a
|
||||
0
|
||||
@ -131,7 +131,7 @@ a
|
||||
10
|
||||
explain select * from t1 where not(a <= 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 9 Using where; Using index
|
||||
select * from t1 where not(a <= 10);
|
||||
a
|
||||
11
|
||||
@ -145,7 +145,7 @@ a
|
||||
19
|
||||
explain select * from t1 where not(a is null);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
|
||||
1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
|
||||
select * from t1 where not(a is null);
|
||||
a
|
||||
0
|
||||
@ -176,7 +176,7 @@ a
|
||||
NULL
|
||||
explain select * from t1 where not(a < 5 or a > 15);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where not(a < 5 or a > 15);
|
||||
a
|
||||
5
|
||||
@ -192,7 +192,7 @@ a
|
||||
15
|
||||
explain select * from t1 where not(a < 15 and a > 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where not(a < 15 and a > 5);
|
||||
a
|
||||
0
|
||||
@ -208,7 +208,7 @@ a
|
||||
19
|
||||
explain select * from t1 where a = 2 or not(a < 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where a = 2 or not(a < 10);
|
||||
a
|
||||
2
|
||||
@ -224,7 +224,7 @@ a
|
||||
19
|
||||
explain select * from t1 where a > 5 and not(a > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index
|
||||
select * from t1 where a > 5 and not(a > 10);
|
||||
a
|
||||
6
|
||||
@ -255,7 +255,7 @@ a
|
||||
19
|
||||
explain select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||
select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||
a
|
||||
2
|
||||
@ -272,7 +272,7 @@ a
|
||||
15
|
||||
explain select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 13 Using where; Using index
|
||||
1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
|
||||
select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||
a
|
||||
0
|
||||
@ -289,7 +289,7 @@ a
|
||||
19
|
||||
explain select * from t1 where NULL or not(a < 15 and a > 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where NULL or not(a < 15 and a > 5);
|
||||
a
|
||||
0
|
||||
@ -327,7 +327,7 @@ a
|
||||
0
|
||||
explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||
a
|
||||
10
|
||||
@ -362,7 +362,7 @@ a
|
||||
19
|
||||
explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||
select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||
a
|
||||
5
|
||||
@ -500,7 +500,7 @@ NULL NULL
|
||||
3 1
|
||||
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index
|
||||
1 SIMPLE t1 index a a 5 NULL 5 80.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` <> 0 AS `not(not(a))`,`test`.`t1`.`a` > 2 or `test`.`t1`.`a` <> 0 AS `not(a <= 2 and not(a))`,`test`.`t1`.`a` like '1' AS `not(a not like "1")`,`test`.`t1`.`a` in (1,2) AS `not (a not in (1,2))`,`test`.`t1`.`a` = 2 AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` <> 0 having `test`.`t1`.`a` <> 0
|
||||
drop table t1;
|
||||
|
@ -187,7 +187,7 @@ Warnings:
|
||||
Warning 1265 Data truncated for column 'i' at row 513
|
||||
explain select * from t1 where i=2 or i is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref i i 4 const 7 Using index
|
||||
1 SIMPLE t1 ref i i 4 const 8 Using index
|
||||
select count(*) from t1 where i=2 or i is null;
|
||||
count(*)
|
||||
9
|
||||
|
@ -18,9 +18,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select * from t1 where a<=>b limit 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index
|
||||
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
|
||||
explain select * from t1 where (a is null or a > 0 and a < 2) and b < 5 limit 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a,b a 9 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range a,b a 9 NULL 2 Using where; Using index
|
||||
explain select * from t1 where (a is null or a = 7) and b=7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null a,b a 9 const,const 2 Using where; Using index
|
||||
@ -257,10 +257,11 @@ uniq_id int(10) unsigned default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
|
||||
INSERT INTO t1 VALUES (11,5),(12,6),(13,7),(14,8),(15,9);
|
||||
INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
|
||||
explain select id from t1 where uniq_id is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref idx1 idx1 5 const 5 Using index condition
|
||||
1 SIMPLE t1 ref idx1 idx1 5 const 6 Using index condition
|
||||
explain select id from t1 where uniq_id =1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const idx1 idx1 5 const 1
|
||||
@ -290,6 +291,11 @@ id uniq_id
|
||||
4 2
|
||||
7 3
|
||||
8 4
|
||||
11 5
|
||||
12 6
|
||||
13 7
|
||||
14 8
|
||||
15 9
|
||||
SELECT * FROM t2 ORDER BY uniq_id, id;
|
||||
id uniq_id
|
||||
3 1
|
||||
|
@ -12,7 +12,7 @@ explain select * from t1 where a is null and b = 2;
|
||||
explain select * from t1 where a is null and b = 7;
|
||||
explain select * from t1 where a=2 and b = 2;
|
||||
explain select * from t1 where a<=>b limit 2;
|
||||
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
|
||||
explain select * from t1 where (a is null or a > 0 and a < 2) and b < 5 limit 3;
|
||||
explain select * from t1 where (a is null or a = 7) and b=7;
|
||||
explain select * from t1 where (a is null or a = 7) and b=7 order by a;
|
||||
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
|
||||
@ -103,8 +103,8 @@ CREATE TABLE t2 (
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
|
||||
INSERT INTO t1 VALUES (11,5),(12,6),(13,7),(14,8),(15,9);
|
||||
INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
|
||||
|
||||
#
|
||||
# Check IS NULL optimization
|
||||
#
|
||||
|
@ -294,81 +294,108 @@ member_id nickname voornaam
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
|
||||
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
|
||||
insert into t1 select * from t1;
|
||||
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 22 NULL 2 Using where; Using index
|
||||
1 SIMPLE t1 range a a 22 NULL 3 Using where; Using index
|
||||
select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
|
||||
a b c
|
||||
1 NULL b
|
||||
1 NULL b
|
||||
explain select * from t1 where a >= 1 and a < 3 order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 4 NULL 22 Using where; Using index
|
||||
select * from t1 where a >= 1 and a < 3 order by a desc;
|
||||
a b c
|
||||
2 3 c
|
||||
2 3 c
|
||||
2 2 b
|
||||
2 2 b
|
||||
2 2 a
|
||||
2 2 a
|
||||
2 1 b
|
||||
2 1 b
|
||||
2 1 a
|
||||
2 1 a
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 NULL
|
||||
1 1 NULL
|
||||
1 NULL b
|
||||
1 NULL b
|
||||
1 NULL NULL
|
||||
1 NULL NULL
|
||||
explain select * from t1 where a = 1 order by a desc, b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 4 const 5 Using where; Using index
|
||||
1 SIMPLE t1 ref a a 4 const 12 Using where; Using index
|
||||
select * from t1 where a = 1 order by a desc, b desc;
|
||||
a b c
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 NULL
|
||||
1 1 NULL
|
||||
1 NULL b
|
||||
1 NULL b
|
||||
1 NULL NULL
|
||||
1 NULL NULL
|
||||
explain select * from t1 where a = 1 and b is null order by a desc, b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 9 const,const 2 Using where; Using index; Using filesort
|
||||
1 SIMPLE t1 ref a a 9 const,const 4 Using where; Using index; Using filesort
|
||||
select * from t1 where a = 1 and b is null order by a desc, b desc;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
1 NULL NULL
|
||||
1 NULL b
|
||||
1 NULL b
|
||||
explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 8 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 18 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 10 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b is null order by a desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
|
||||
explain select * from t1 where a = 2 and (b is null or b > 0) order by a
|
||||
desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 6 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 11 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 10 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
|
||||
explain select * from t1 where a = 1 order by b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 4 const 5 Using where; Using index
|
||||
1 SIMPLE t1 ref a a 4 const 12 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc,b,a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 10 Using where; Using index
|
||||
explain select * from t1 where a = 2 and b < 2 order by a desc,a,b desc,a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
|
||||
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
|
||||
select * from t1 where a = 1 order by b desc;
|
||||
a b c
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 NULL
|
||||
1 1 NULL
|
||||
1 NULL b
|
||||
1 NULL b
|
||||
1 NULL NULL
|
||||
1 NULL NULL
|
||||
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
|
||||
alter table t1 modify b int not null, modify c varchar(10) not null;
|
||||
@ -377,91 +404,146 @@ Warning 1265 Data truncated for column 'b' at row 1
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'c' at row 3
|
||||
Warning 1265 Data truncated for column 'b' at row 12
|
||||
Warning 1265 Data truncated for column 'c' at row 12
|
||||
Warning 1265 Data truncated for column 'b' at row 13
|
||||
Warning 1265 Data truncated for column 'c' at row 14
|
||||
explain select * from t1 order by a, b, c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 20 NULL 11 Using index
|
||||
1 SIMPLE t1 index NULL a 20 NULL 22 Using index
|
||||
select * from t1 order by a, b, c;
|
||||
a b c
|
||||
1 0
|
||||
1 0
|
||||
1 0 b
|
||||
1 0 b
|
||||
1 1
|
||||
1 1
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 3 b
|
||||
1 3 b
|
||||
2 1 a
|
||||
2 1 a
|
||||
2 1 b
|
||||
2 1 b
|
||||
2 2 a
|
||||
2 2 a
|
||||
2 2 b
|
||||
2 2 b
|
||||
2 3 c
|
||||
2 3 c
|
||||
explain select * from t1 order by a desc, b desc, c desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 20 NULL 11 Using index
|
||||
1 SIMPLE t1 index NULL a 20 NULL 22 Using index
|
||||
select * from t1 order by a desc, b desc, c desc;
|
||||
a b c
|
||||
2 3 c
|
||||
2 3 c
|
||||
2 2 b
|
||||
2 2 b
|
||||
2 2 a
|
||||
2 2 a
|
||||
2 1 b
|
||||
2 1 b
|
||||
2 1 a
|
||||
2 1 a
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1
|
||||
1 1
|
||||
1 0 b
|
||||
1 0 b
|
||||
1 0
|
||||
1 0
|
||||
explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 20 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range a a 20 NULL 5 Using where; Using index
|
||||
select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
|
||||
a b c
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 6 Using where; Using index
|
||||
1 SIMPLE t1 range a a 4 NULL 12 Using where; Using index
|
||||
select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
|
||||
a b c
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1
|
||||
1 1
|
||||
1 0 b
|
||||
1 0 b
|
||||
1 0
|
||||
1 0
|
||||
select count(*) from t1 where a < 5 and b > 0;
|
||||
count(*)
|
||||
9
|
||||
18
|
||||
select * from t1 where a < 5 and b > 0 order by a desc,b desc;
|
||||
a b c
|
||||
2 3 c
|
||||
2 3 c
|
||||
2 2 b
|
||||
2 2 b
|
||||
2 2 a
|
||||
2 2 a
|
||||
2 1 b
|
||||
2 1 b
|
||||
2 1 a
|
||||
2 1 a
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1
|
||||
1 1
|
||||
explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 8 NULL 10 Using where; Using index
|
||||
1 SIMPLE t1 range a a 8 NULL 22 Using where; Using index
|
||||
select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
|
||||
a b c
|
||||
2 1 b
|
||||
2 1 b
|
||||
2 1 a
|
||||
2 1 a
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1
|
||||
1 1
|
||||
1 0 b
|
||||
1 0 b
|
||||
1 0
|
||||
1 0
|
||||
explain select * from t1 where a between 0 and 1 order by a desc, b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 range a a 4 NULL 12 Using where; Using index
|
||||
select * from t1 where a between 0 and 1 order by a desc, b desc;
|
||||
a b c
|
||||
1 3 b
|
||||
1 3 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1 b
|
||||
1 1
|
||||
1 1
|
||||
1 0 b
|
||||
1 0 b
|
||||
1 0
|
||||
1 0
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
@ -621,10 +703,10 @@ DS-MRR: use two IGNORE INDEX queries, otherwise we get cost races, because
|
||||
DS-MRR: records_in_range/read_time return the same numbers for all three indexes
|
||||
EXPLAIN SELECT * FROM t1 IGNORE INDEX (LongField, StringField) WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range FieldKey FieldKey 38 NULL 4 Using index condition; Using filesort
|
||||
1 SIMPLE t1 range FieldKey FieldKey 38 NULL 3 Using index condition; Using filesort
|
||||
EXPLAIN SELECT * FROM t1 IGNORE INDEX (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range StringField StringField 38 NULL 4 Using where; Using filesort
|
||||
1 SIMPLE t1 range StringField StringField 38 NULL 3 Using where; Using filesort
|
||||
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
|
||||
FieldKey LongVal StringVal
|
||||
3 1 2
|
||||
@ -632,7 +714,7 @@ FieldKey LongVal StringVal
|
||||
3 3 3
|
||||
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 4 Using where
|
||||
1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 3 Using where
|
||||
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
|
||||
FieldKey LongVal StringVal
|
||||
3 1 2
|
||||
@ -663,7 +745,7 @@ a b
|
||||
4 NULL
|
||||
explain select * from t1 where b=2 or b is null order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null b b 5 const 3 Using index condition; Using where; Using filesort
|
||||
1 SIMPLE t1 ref_or_null b b 5 const 4 Using index condition; Using where; Using filesort
|
||||
select * from t1 where b=2 or b is null order by a;
|
||||
a b
|
||||
3 NULL
|
||||
@ -784,8 +866,6 @@ key `wnid` (`wnid`)
|
||||
) engine=myisam default charset=latin1;
|
||||
insert into t1 (`sid`, `wnid`) values
|
||||
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
|
||||
('39560','01019090000'),('37989','01019000000'),('37990','01019011000'),
|
||||
('37991','01019011000'),('37992','01019019000'),('37993','01019030000'),
|
||||
('37994','01019090000'),('475','02070000000'),('25253','02071100000'),
|
||||
('25255','02071100000'),('25256','02071110000'),('25258','02071130000'),
|
||||
('25259','02071190000'),('25260','02071200000'),('25261','02071210000'),
|
||||
@ -800,18 +880,12 @@ insert into t1 (`sid`, `wnid`) values
|
||||
('25295','02071491000'),('25296','02071491000'),('25297','02071499000');
|
||||
explain select * from t1 where wnid like '0101%' order by wnid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range wnid14,wnid wnid 13 NULL 10 Using where
|
||||
1 SIMPLE t1 range wnid14,wnid wnid 13 NULL 4 Using where
|
||||
select * from t1 where wnid like '0101%' order by wnid;
|
||||
sid wnid
|
||||
10100 01019000000
|
||||
37986 01019000000
|
||||
37989 01019000000
|
||||
37987 01019010000
|
||||
37990 01019011000
|
||||
37991 01019011000
|
||||
37992 01019019000
|
||||
37993 01019030000
|
||||
39560 01019090000
|
||||
37994 01019090000
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
@ -2851,7 +2925,7 @@ explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 502 Using where; Using index; Using temporary; Using filesort
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 503 Using where; Using index; Using temporary; Using filesort
|
||||
flush status;
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
@ -2870,7 +2944,7 @@ explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 502 Using where; Using index; Using temporary; Using filesort
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 503 Using where; Using index; Using temporary; Using filesort
|
||||
flush status;
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
@ -3034,15 +3108,17 @@ KEY id_234_date (id2,id3,id4,date)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
# t2 has a "good" index declaration order
|
||||
INSERT INTO t1 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t1 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t2 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t2 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
# The following two must both use id_23_date and no "using filesort":
|
||||
EXPLAIN SELECT id1 FROM t1 WHERE id2=1 AND id3=1 ORDER BY date DESC LIMIT 0,4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range id_234_date,id_23_date id_23_date 2 NULL 3 Using where
|
||||
1 SIMPLE t1 range id_234_date,id_23_date id_23_date 2 NULL 8 Using where
|
||||
# See above query
|
||||
EXPLAIN SELECT id1 FROM t2 WHERE id2=1 AND id3=1 ORDER BY date DESC LIMIT 0,4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref id_23_date,id_234_date id_23_date 2 const,const 3 Using where
|
||||
1 SIMPLE t2 ref id_23_date,id_234_date id_23_date 2 const,const 8 Using where
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-8989: ORDER BY optimizer ignores equality propagation
|
||||
@ -3246,9 +3322,9 @@ WHERE books.library_id = 8663 AND
|
||||
books.scheduled_for_removal=0 )
|
||||
ORDER BY wings.id;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 100.00 Using temporary; Using filesort
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
1 PRIMARY wings eq_ref PRIMARY PRIMARY 4 test.books.wings_id 1 100.00
|
||||
2 MATERIALIZED books ref library_idx library_idx 4 const 1 100.00 Using where
|
||||
2 MATERIALIZED books ref library_idx library_idx 4 const 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`wings`.`id` AS `wing_id`,`test`.`wings`.`department_id` AS `department_id` from `test`.`wings` semi join (`test`.`books`) where `test`.`books`.`library_id` = 8663 and `test`.`books`.`scheduled_for_removal` = 0 and `test`.`wings`.`id` = `test`.`books`.`wings_id` order by `test`.`wings`.`id`
|
||||
set optimizer_switch= @save_optimizer_switch;
|
||||
|
@ -246,6 +246,7 @@ drop table t1;
|
||||
|
||||
create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
|
||||
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
|
||||
insert into t1 select * from t1;
|
||||
|
||||
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
|
||||
select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
|
||||
@ -551,8 +552,6 @@ create table t1 (
|
||||
|
||||
insert into t1 (`sid`, `wnid`) values
|
||||
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
|
||||
('39560','01019090000'),('37989','01019000000'),('37990','01019011000'),
|
||||
('37991','01019011000'),('37992','01019019000'),('37993','01019030000'),
|
||||
('37994','01019090000'),('475','02070000000'),('25253','02071100000'),
|
||||
('25255','02071100000'),('25256','02071110000'),('25258','02071130000'),
|
||||
('25259','02071190000'),('25260','02071200000'),('25261','02071210000'),
|
||||
@ -2039,6 +2038,8 @@ CREATE TABLE t2 (
|
||||
--echo # t2 has a "good" index declaration order
|
||||
|
||||
INSERT INTO t1 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t1 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t2 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
INSERT INTO t2 (id2,id3,id4) VALUES (1,1,1),(1,1,1),(1,1,1),(1,1,1),(1,0,1),(1,2,1),(1,3,1);
|
||||
|
||||
--echo # The following two must both use id_23_date and no "using filesort":
|
||||
|
@ -2357,7 +2357,7 @@ b c
|
||||
EXPLAIN
|
||||
SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by
|
||||
1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #45807: crash accessing partitioned table and sql_mode
|
||||
|
@ -1,6 +1,11 @@
|
||||
call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction");
|
||||
set global default_storage_engine='innodb';
|
||||
set session default_storage_engine='innodb';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
drop table if exists t1, t2;
|
||||
#
|
||||
# Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST
|
||||
@ -24,12 +29,15 @@ INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
|
||||
(20, '0'), (21, '1'), (22, '2'), (23, '3'),
|
||||
(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
|
||||
INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 60, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 120, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 240, b FROM t1 WHERE a >= 0;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY,b b 67 NULL 34 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY,b b 67 NULL 90 Using where; Using index
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY
|
||||
@ -663,7 +671,7 @@ EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
|
||||
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
|
||||
GROUP BY 1, 2, 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY,col1,col2 PRIMARY 5 NULL # Using where; Using filesort
|
||||
1 SIMPLE t1 ref PRIMARY,col1,col2 col1 8 const # Using where; Using filesort
|
||||
SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2
|
||||
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
|
||||
GROUP BY 1, 2, 3;
|
||||
@ -696,9 +704,11 @@ insert into t1 select 10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
||||
10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
||||
2000 + A.a + 10*B.a + 100*C.a + 1000*D.a
|
||||
from t2 A, t2 B, t2 C ,t2 D;
|
||||
set statement optimizer_switch='rowid_filter=off' for
|
||||
explain select * from t1 where a=1 and b=2 and pk between 1 and 999999 ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge PRIMARY,a,b b,a 4,4 NULL # Using intersect(b,a); Using where; Using index
|
||||
set statement optimizer_switch='rowid_filter=off' for
|
||||
create temporary table t3 as
|
||||
select * from t1 where a=1 and b=2 and pk between 1 and 999 ;
|
||||
select count(*) from t3;
|
||||
@ -925,3 +935,6 @@ test_jfg test_jfg11
|
||||
test_jfg test_jfg12#P#p1000
|
||||
test_jfg test_jfg12#P#pmax
|
||||
DROP DATABASE test_jfg;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -7,6 +7,13 @@ call mtr.add_suppression("Deadlock found when trying to get lock; try restarting
|
||||
set global default_storage_engine='innodb';
|
||||
set session default_storage_engine='innodb';
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
@ -38,6 +45,9 @@ INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
|
||||
(20, '0'), (21, '1'), (22, '2'), (23, '3'),
|
||||
(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
|
||||
INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 60, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 120, b FROM t1 WHERE a >= 0;
|
||||
INSERT INTO t1 SELECT a + 240, b FROM t1 WHERE a >= 0;
|
||||
ANALYZE TABLE t1;
|
||||
EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
|
||||
DROP TABLE t1;
|
||||
@ -772,8 +782,10 @@ insert into t1 select 10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
||||
|
||||
# This should show index_merge, using intersect
|
||||
--replace_column 9 #
|
||||
set statement optimizer_switch='rowid_filter=off' for
|
||||
explain select * from t1 where a=1 and b=2 and pk between 1 and 999999 ;
|
||||
# 794 rows in output
|
||||
set statement optimizer_switch='rowid_filter=off' for
|
||||
create temporary table t3 as
|
||||
select * from t1 where a=1 and b=2 and pk between 1 and 999 ;
|
||||
select count(*) from t3;
|
||||
@ -1015,3 +1027,7 @@ SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
|
||||
database_name = 'test_jfg';
|
||||
|
||||
DROP DATABASE test_jfg;
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -18,7 +18,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
# # # # # # # # # 3 #
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
# # # # # # # # # 9 #
|
||||
# # # # # # # # # 10 #
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
# # # # # # # # # 3 #
|
||||
@ -105,7 +105,7 @@ a
|
||||
6
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a <= 1;
|
||||
a
|
||||
-1
|
||||
@ -168,7 +168,7 @@ a
|
||||
6
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a <= 7;
|
||||
a
|
||||
-1
|
||||
@ -182,7 +182,7 @@ a
|
||||
7
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a = 1;
|
||||
a
|
||||
1
|
||||
@ -424,7 +424,7 @@ a
|
||||
5
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a <= 1;
|
||||
a
|
||||
-1
|
||||
@ -474,7 +474,7 @@ a
|
||||
5
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a <= 6;
|
||||
a
|
||||
-1
|
||||
@ -487,7 +487,7 @@ a
|
||||
6
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
|
||||
1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
|
||||
SELECT * FROM t1 WHERE a = 1;
|
||||
a
|
||||
1
|
||||
@ -744,41 +744,41 @@ a
|
||||
1001-01-01
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
# Disabling warnings for the invalid date
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
|
||||
@ -790,16 +790,16 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
# test without index
|
||||
ALTER TABLE t1 DROP KEY a;
|
||||
SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
@ -1073,41 +1073,41 @@ a
|
||||
1001-01-01
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
# Disabling warnings for the invalid date
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
|
||||
@ -1119,16 +1119,16 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
# test without index
|
||||
ALTER TABLE t1 DROP KEY a;
|
||||
SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
@ -1402,41 +1402,41 @@ a
|
||||
1001-01-01
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
# Disabling warnings for the invalid date
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
|
||||
@ -1448,16 +1448,16 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
|
||||
# test without index
|
||||
ALTER TABLE t1 DROP KEY a;
|
||||
SELECT * FROM t1 WHERE a < '1001-01-01';
|
||||
@ -2670,12 +2670,14 @@ create table t1 (a int not null, b int not null, key(a), key(b))
|
||||
partition by hash(a) partitions 4;
|
||||
insert into t1 values (1,1),(2,2),(3,3),(4,4);
|
||||
insert into t1 values (5,5),(6,6),(7,7),(8,8);
|
||||
insert into t1 values (9,9),(10,10),(11,11),(12,12);
|
||||
insert into t1 values (13,13),(14,14),(15,15),(16,16);
|
||||
explain partitions
|
||||
select * from t1 X, t1 Y
|
||||
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where
|
||||
1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 2 Using where
|
||||
1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using filter
|
||||
explain partitions
|
||||
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
@ -2867,15 +2869,15 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2 ALL NULL NULL NULL NULL 510 Using where
|
||||
explain partitions select * from t2 where b = 4;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 77
|
||||
explain extended select * from t2 where b = 6;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ref b b 5 const 76 100.00
|
||||
1 SIMPLE t2 ref b b 5 const 77 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` = 6
|
||||
explain partitions select * from t2 where b = 6;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 77
|
||||
explain extended select * from t2 where b in (1,3,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 40.66 Using where
|
||||
@ -2886,7 +2888,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
|
||||
explain extended select * from t2 where b in (2,4,6);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 25.05 Using where
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 25.38 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` in (2,4,6)
|
||||
explain partitions select * from t2 where b in (2,4,6);
|
||||
@ -2894,7 +2896,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
|
||||
explain extended select * from t2 where b in (7,8,9);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 36.70 Using where
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 36.81 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` in (7,8,9)
|
||||
explain partitions select * from t2 where b in (7,8,9);
|
||||
@ -2902,7 +2904,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
|
||||
explain extended select * from t2 where b > 5;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 44.84 Using where
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 44.62 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 5
|
||||
explain partitions select * from t2 where b > 5;
|
||||
@ -2910,7 +2912,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
|
||||
explain extended select * from t2 where b > 5 and b < 8;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 22.09 Using where
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 22.20 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 5 and `test`.`t2`.`b` < 8
|
||||
explain partitions select * from t2 where b > 5 and b < 8;
|
||||
@ -2918,15 +2920,15 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
|
||||
explain extended select * from t2 where b > 5 and b < 7;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 range b b 5 NULL 76 100.00 Using where
|
||||
1 SIMPLE t2 range b b 5 NULL 77 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 5 and `test`.`t2`.`b` < 7
|
||||
explain partitions select * from t2 where b > 5 and b < 7;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 76 Using where
|
||||
1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 77 Using where
|
||||
explain extended select * from t2 where b > 0 and b < 5;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 41.65 Using where
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 910 41.87 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 0 and `test`.`t2`.`b` < 5
|
||||
explain partitions select * from t2 where b > 0 and b < 5;
|
||||
@ -3376,16 +3378,16 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1 const PRIMARY PRIMARY 8 const,const 1
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 < 3;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 1 Using where
|
||||
1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
@ -3394,7 +3396,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 3;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 1 Using where
|
||||
1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 > 3;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 1 Using where
|
||||
@ -3403,7 +3405,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
|
||||
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
|
||||
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1
|
||||
@ -3463,7 +3465,7 @@ select * from t1
|
||||
where company_id = 1000
|
||||
and dept_id in (select dept_id from t2 where COMPANY_ID = 1000);
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 p_1000 ref PRIMARY PRIMARY 8 const 2 Using index
|
||||
1 PRIMARY t2 p_1000 ref PRIMARY PRIMARY 8 const 3 Using index
|
||||
1 PRIMARY t1 p_1000 ALL PRIMARY NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
#
|
||||
|
@ -892,6 +892,8 @@ create table t1 (a int not null, b int not null, key(a), key(b))
|
||||
partition by hash(a) partitions 4;
|
||||
insert into t1 values (1,1),(2,2),(3,3),(4,4);
|
||||
insert into t1 values (5,5),(6,6),(7,7),(8,8);
|
||||
insert into t1 values (9,9),(10,10),(11,11),(12,12);
|
||||
insert into t1 values (13,13),(14,14),(15,15),(16,16);
|
||||
|
||||
explain partitions
|
||||
select * from t1 X, t1 Y
|
||||
|
@ -958,13 +958,17 @@ INSERT INTO t1 SELECT a + 10, b + 10 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 20, b + 20 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 40, b + 40 FROM t1;
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
ANALYZE TABLE t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Table is already up to date
|
||||
# plans should be identical
|
||||
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by
|
||||
1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index
|
||||
FLUSH status;
|
||||
SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a;
|
||||
a MAX(b)
|
||||
@ -980,5 +984,5 @@ a MAX(b)
|
||||
# Should be no more than 4 reads.
|
||||
SHOW status LIKE 'handler_read_key';
|
||||
Variable_name Value
|
||||
Handler_read_key 4
|
||||
Handler_read_key 2
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -957,6 +957,8 @@ INSERT INTO t1 SELECT a + 40, b + 40 FROM t1;
|
||||
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
|
||||
ANALYZE TABLE t1,t2;
|
||||
|
||||
--echo # plans should be identical
|
||||
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a;
|
||||
EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
|
||||
|
@ -55,14 +55,14 @@ count(*)
|
||||
4181
|
||||
show status like "key_read%";
|
||||
Variable_name Value
|
||||
Key_read_requests 294
|
||||
Key_read_requests 297
|
||||
Key_reads 60
|
||||
select count(*) from t1 where b = 'test1';
|
||||
count(*)
|
||||
4181
|
||||
show status like "key_read%";
|
||||
Variable_name Value
|
||||
Key_read_requests 588
|
||||
Key_read_requests 594
|
||||
Key_reads 60
|
||||
flush tables;
|
||||
flush status;
|
||||
@ -81,7 +81,7 @@ count(*)
|
||||
4181
|
||||
show status like "key_read%";
|
||||
Variable_name Value
|
||||
Key_read_requests 1068
|
||||
Key_read_requests 1071
|
||||
Key_reads 774
|
||||
flush tables;
|
||||
flush status;
|
||||
@ -105,7 +105,7 @@ count(*)
|
||||
4181
|
||||
show status like "key_read%";
|
||||
Variable_name Value
|
||||
Key_read_requests 311
|
||||
Key_read_requests 314
|
||||
Key_reads 75
|
||||
flush tables;
|
||||
flush status;
|
||||
@ -133,7 +133,7 @@ count(*)
|
||||
2584
|
||||
show status like "key_read%";
|
||||
Variable_name Value
|
||||
Key_read_requests 1266
|
||||
Key_read_requests 1272
|
||||
Key_reads 821
|
||||
flush tables;
|
||||
flush status;
|
||||
|
@ -451,7 +451,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 14 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
@ -462,15 +462,15 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
|
||||
def id 8 3 1 Y 32928 0 63
|
||||
def select_type 253 19 6 N 1 39 8
|
||||
def table 253 64 2 Y 0 39 8
|
||||
def type 253 10 5 Y 0 39 8
|
||||
def type 253 10 3 Y 0 39 8
|
||||
def possible_keys 253 4_OR_8_K 7 Y 0 39 8
|
||||
def key 253 64 7 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 1 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def Extra 253 255 37 N 1 39 8
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 27 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using index condition; Using filesort
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using filesort
|
||||
drop table if exists t2;
|
||||
create table t2 (id smallint, name varchar(20)) ;
|
||||
prepare stmt1 from ' insert into t2 values(?, ?) ' ;
|
||||
|
@ -1161,7 +1161,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 0 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
|
||||
|
@ -1161,7 +1161,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 0 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
|
||||
|
@ -1162,7 +1162,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 0 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
|
||||
|
@ -1205,7 +1205,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 0 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
|
||||
@ -4573,7 +4573,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
|
||||
def key 253 64 0 Y 0 39 8
|
||||
def key_len 253 4_OR_8_K 0 Y 0 39 8
|
||||
def ref 253 2048 0 Y 0 39 8
|
||||
def rows 8 10 1 Y 32928 0 63
|
||||
def rows 253 64 1 Y 0 39 8
|
||||
def Extra 253 255 0 N 1 39 8
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
|
||||
|
@ -1,3 +1,8 @@
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
CREATE TABLE t1 (
|
||||
event_date date DEFAULT '0000-00-00' NOT NULL,
|
||||
type int(11) DEFAULT '0' NOT NULL,
|
||||
@ -244,7 +249,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select count(*) from t1 where x in (1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref x x 5 const 1 Using index
|
||||
explain select count(*) from t1 where x in (1,2);
|
||||
explain select count(*) from t1 where x in (1,2,3,4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index
|
||||
drop table t1;
|
||||
@ -420,19 +425,19 @@ test.t1 analyze status OK
|
||||
test.t2 analyze status Table is already up to date
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 111 Using index condition
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 111 Using index condition
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using index condition
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using index condition
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
|
||||
id name uid id name uid
|
||||
@ -715,7 +720,7 @@ WHERE
|
||||
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
|
||||
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using index condition
|
||||
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition
|
||||
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
|
||||
SELECT s.oxid FROM t1 v, t1 s
|
||||
WHERE
|
||||
@ -892,12 +897,13 @@ INSERT INTO t1 VALUES
|
||||
(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
|
||||
(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
|
||||
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
|
||||
INSERT INTO t1(status) SELECT status FROM t1;
|
||||
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using index condition
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using index condition
|
||||
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using index condition
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using index condition
|
||||
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -908,6 +914,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
SELECT * FROM t1 WHERE status NOT IN ('A','B');
|
||||
id status
|
||||
53 C
|
||||
@ -918,18 +932,26 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using where; Using index
|
||||
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using where; Using index
|
||||
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 10 Using index condition
|
||||
1 SIMPLE t1 range status status 23 NULL 17 Using index condition
|
||||
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Using where
|
||||
1 SIMPLE t1 range status status 23 NULL 17 Using index condition; Using where
|
||||
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -940,6 +962,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -950,6 +980,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, primary key(a,b));
|
||||
INSERT INTO t1 VALUES
|
||||
@ -957,16 +995,16 @@ INSERT INTO t1 VALUES
|
||||
CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
|
||||
EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
SELECT a,b FROM t1 WHERE a < 2 and b=3;
|
||||
a b
|
||||
1 3
|
||||
@ -1006,10 +1044,10 @@ INSERT INTO `t1` VALUES
|
||||
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
|
||||
explain select * from t1 where a in (3,4) and b in (1,2,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
explain select * from v1 where a in (3,4) and b in (1,2,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
@ -1065,10 +1103,10 @@ id b c
|
||||
0 3 4
|
||||
EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using index condition; Using where
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using index condition; Using where
|
||||
EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using where
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
|
||||
id b c
|
||||
0 3 4
|
||||
@ -1079,10 +1117,10 @@ id b c
|
||||
0 3 4
|
||||
EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 Using sort_union(idx1,idx2); Using where
|
||||
EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 Using sort_union(idx1,idx2); Using where
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
item char(20) NOT NULL default '',
|
||||
@ -1097,7 +1135,7 @@ INSERT INTO t1 VALUES
|
||||
('A2','2005-12-01 08:00:00',1000);
|
||||
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using index condition
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 3 Using index condition
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
item started price
|
||||
Warnings:
|
||||
@ -1141,7 +1179,7 @@ CREATE TABLE t1 (
|
||||
a varchar(32), index (a)
|
||||
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
|
||||
INSERT INTO t1 VALUES
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'), ('C'), ('A');
|
||||
SELECT a FROM t1 WHERE a='b' OR a='B';
|
||||
a
|
||||
B
|
||||
@ -1201,13 +1239,15 @@ Z
|
||||
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
|
||||
explain select * from t2 where a=1000 and b<11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref a a 5 const 502 Using index condition
|
||||
1 SIMPLE t2 ref a a 5 const 503 Using index condition
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1( a INT, b INT, KEY( a, b ) );
|
||||
CREATE TABLE t2( a INT, b INT, KEY( a, b ) );
|
||||
CREATE TABLE t3( a INT, b INT, KEY( a, b ) );
|
||||
INSERT INTO t1( a, b )
|
||||
VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7);
|
||||
INSERT INTO t1( a, b ) VALUES
|
||||
(0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7),
|
||||
(10, 11), (11,12), (11, 14), (12, 13), (15, 10), (19, 17),
|
||||
(20, 21), (21,22), (21, 24), (22, 23), (25, 20), (29, 27);
|
||||
INSERT INTO t2( a, b )
|
||||
VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1),
|
||||
( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1),
|
||||
@ -1218,65 +1258,67 @@ INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t3
|
||||
VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0);
|
||||
INSERT INTO t3 VALUES
|
||||
(1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0),
|
||||
(11, 0), (12, 0), (13, 0), (14, 0), (15, 0),
|
||||
(16, 0), (17, 0), (18, 0), (19, 0), (20, 0);
|
||||
INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t2 WHERE
|
||||
5 <= a AND a < 10 AND b = 1 OR
|
||||
15 <= a AND a < 20 AND b = 3
|
||||
@ -1315,7 +1357,7 @@ SELECT * FROM t2 WHERE
|
||||
OR
|
||||
1 <= a AND b = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 10 NULL 50 Using where; Using index
|
||||
1 SIMPLE t2 range a a 10 NULL 49 Using where; Using index
|
||||
SELECT * FROM t2 WHERE
|
||||
5 <= a AND a < 10 AND b = 2 OR
|
||||
15 <= a AND a < 20 AND b = 3
|
||||
@ -1359,7 +1401,7 @@ SELECT * FROM t2 WHERE
|
||||
OR
|
||||
1 <= a AND b = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 10 NULL 50 Using where; Using index
|
||||
1 SIMPLE t2 range a a 10 NULL 49 Using where; Using index
|
||||
SELECT * FROM t3 WHERE
|
||||
5 <= a AND a < 10 AND b = 3 OR
|
||||
a < 5 OR
|
||||
@ -1380,7 +1422,7 @@ SELECT * FROM t3 WHERE
|
||||
a < 5 OR
|
||||
a < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range a a 5 NULL 8 Using where; Using index
|
||||
1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
|
||||
@ -1398,10 +1440,16 @@ CREATE TABLE t2 ( a DATETIME, KEY ( a ) );
|
||||
# Make optimizer choose range scan
|
||||
INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22');
|
||||
INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23');
|
||||
INSERT INTO t1 VALUES ('2009-09-20'), ('2009-09-20'), ('2009-09-20');
|
||||
INSERT INTO t1 VALUES ('2009-09-21'), ('2009-09-21'), ('2009-09-21');
|
||||
INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'),
|
||||
('2009-09-22 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'),
|
||||
('2009-09-23 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-20 12:00:00'), ('2009-09-20 12:00:00'),
|
||||
('2009-09-20 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-21 12:00:00'), ('2009-09-21 12:00:00'),
|
||||
('2009-09-21 12:00:00');
|
||||
# DATE vs DATE
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE a >= '2009/09/23';
|
||||
@ -1656,7 +1704,8 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
|
||||
CREATE UNIQUE INDEX i4_uq ON t1(i4);
|
||||
INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
|
||||
INSERT INTO t1 VALUES
|
||||
(1,10), (2,20), (3,30), (4,40), (5,50), (6,60), (7,70), (8,80);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1672,14 +1721,13 @@ SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
|
||||
pk i4
|
||||
1 10
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 3 Using index condition
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1690,12 +1738,17 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
4 40
|
||||
5 50
|
||||
6 60
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1715,14 +1768,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
|
||||
pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1732,7 +1784,7 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 1 Using index condition
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
|
||||
pk i4
|
||||
1 10
|
||||
@ -1740,14 +1792,14 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 8
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
|
||||
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
|
||||
pk i4 pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 8
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
|
||||
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
|
||||
pk i4 pk i4
|
||||
@ -1893,19 +1945,23 @@ insert into t2 select a+16 from t2;
|
||||
insert into t2 select a+32 from t2;
|
||||
insert into t2 select a+64 from t2;
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 64
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
count(*)
|
||||
128
|
||||
832
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 64
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
count(*)
|
||||
126
|
||||
drop table t1,t2;
|
||||
@ -1919,7 +1975,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1);
|
||||
explain
|
||||
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index
|
||||
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
|
||||
a b c
|
||||
2 2 0
|
||||
@ -1949,7 +2005,7 @@ INSERT INTO t100(I,J) VALUES(8,26);
|
||||
|
||||
EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t100 range I I 10 NULL 4 Using index condition; Using where
|
||||
1 SIMPLE t100 range I I 10 NULL 3 Using index condition; Using where
|
||||
|
||||
SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
|
||||
K I J
|
||||
@ -2272,10 +2328,10 @@ CREATE TABLE t1 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t1 (a) VALUES (10),(10),(10),(10),(10),(10),(10),(10),(10),(10),(70);
|
||||
EXPLAIN SELECT * FROM t1 WHERE a<>10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using index condition
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using index condition
|
||||
EXPLAIN SELECT * FROM t1 WHERE 10<>a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using index condition
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using index condition
|
||||
SELECT * FROM t1 WHERE a<>10;
|
||||
a b
|
||||
70 NULL
|
||||
@ -2333,7 +2389,7 @@ insert into t1 values
|
||||
# range access to t1 by 2-component keys for index idx
|
||||
explain select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 10 NULL 7 Using where
|
||||
1 SIMPLE t1 range idx idx 10 NULL 6 Using where
|
||||
explain format=json select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7));
|
||||
EXPLAIN
|
||||
{
|
||||
@ -2346,7 +2402,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "10",
|
||||
"used_key_parts": ["a", "b"],
|
||||
"rows": 7,
|
||||
"rows": 6,
|
||||
"filtered": 100,
|
||||
"attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))"
|
||||
}
|
||||
@ -2530,7 +2586,7 @@ explain select * from t1,t2
|
||||
where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 5 NULL 6 Using index condition
|
||||
1 SIMPLE t2 ref idx1,idx2 idx1 5 test.t1.a 12 Using where
|
||||
1 SIMPLE t2 ref|filter idx1,idx2 idx1|idx2 5|5 test.t1.a 12 (14%) Using where; Using filter
|
||||
explain format=json select * from t1,t2
|
||||
where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1;
|
||||
EXPLAIN
|
||||
@ -2556,6 +2612,14 @@ EXPLAIN
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["d"],
|
||||
"ref": ["test.t1.a"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "idx2",
|
||||
"used_key_parts": ["e"]
|
||||
},
|
||||
"rows": 15,
|
||||
"selectivity_pct": 14.423
|
||||
},
|
||||
"rows": 12,
|
||||
"filtered": 100,
|
||||
"attached_condition": "(t1.a,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1"
|
||||
@ -2626,7 +2690,7 @@ insert into t1 select * from t1;
|
||||
explain select * from t1,t2
|
||||
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range idx1,idx2 idx2 5 NULL 6 Using where
|
||||
1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 7 (7%) Using index condition; Using where; Using filter
|
||||
1 SIMPLE t1 ref idx idx 5 test.t2.d 11
|
||||
explain format=json select * from t1,t2
|
||||
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
|
||||
@ -2638,12 +2702,21 @@ EXPLAIN
|
||||
"table_name": "t2",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["idx1", "idx2"],
|
||||
"key": "idx2",
|
||||
"key": "idx1",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["e"],
|
||||
"rows": 6,
|
||||
"used_key_parts": ["d"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "idx2",
|
||||
"used_key_parts": ["e"]
|
||||
},
|
||||
"rows": 7,
|
||||
"selectivity_pct": 6.7308
|
||||
},
|
||||
"rows": 7,
|
||||
"filtered": 100,
|
||||
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1 and t2.d is not null"
|
||||
"index_condition": "t2.d is not null",
|
||||
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "t1",
|
||||
@ -2828,7 +2901,7 @@ explain select * from t1,t2
|
||||
where a = d and (a,2) in ((2,2),(7,7),(8,8)) and
|
||||
length(c) = 1 and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 5 NULL 13 Using index condition; Using where
|
||||
1 SIMPLE t1 range idx idx 5 NULL 12 Using index condition; Using where
|
||||
1 SIMPLE t2 ref idx3 idx3 5 test.t1.a 3 Using where
|
||||
explain format=json select * from t1,t2
|
||||
where a = d and (a,2) in ((2,2),(7,7),(8,8)) and
|
||||
@ -2844,7 +2917,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 13,
|
||||
"rows": 12,
|
||||
"filtered": 100,
|
||||
"index_condition": "t1.a is not null",
|
||||
"attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1"
|
||||
@ -2904,7 +2977,7 @@ where id = 1 and a = d and
|
||||
length(c) = 1 and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1
|
||||
1 SIMPLE t1 range idx idx 5 NULL 13 Using index condition; Using where
|
||||
1 SIMPLE t1 range idx idx 5 NULL 12 Using index condition; Using where
|
||||
1 SIMPLE t2 ref idx3 idx3 5 test.t1.a 3 Using where
|
||||
explain format=json select * from t1,t2,t3
|
||||
where id = 1 and a = d and
|
||||
@ -2932,7 +3005,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 13,
|
||||
"rows": 12,
|
||||
"filtered": 100,
|
||||
"index_condition": "t1.a is not null",
|
||||
"attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1"
|
||||
@ -3024,3 +3097,6 @@ drop table t1;
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -3,6 +3,13 @@
|
||||
#
|
||||
--source include/have_innodb.inc
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
event_date date DEFAULT '0000-00-00' NOT NULL,
|
||||
type int(11) DEFAULT '0' NOT NULL,
|
||||
@ -188,7 +195,7 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
|
||||
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
|
||||
# testing IN
|
||||
explain select count(*) from t1 where x in (1);
|
||||
explain select count(*) from t1 where x in (1,2);
|
||||
explain select count(*) from t1 where x in (1,2,3,4);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
@ -745,6 +752,7 @@ INSERT INTO t1 VALUES
|
||||
(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
|
||||
(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
|
||||
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
|
||||
INSERT INTO t1(status) SELECT status FROM t1;
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
|
||||
@ -950,7 +958,7 @@ CREATE TABLE t1 (
|
||||
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'), ('C'), ('A');
|
||||
|
||||
SELECT a FROM t1 WHERE a='b' OR a='B';
|
||||
EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B';
|
||||
@ -1040,8 +1048,10 @@ CREATE TABLE t2( a INT, b INT, KEY( a, b ) );
|
||||
|
||||
CREATE TABLE t3( a INT, b INT, KEY( a, b ) );
|
||||
|
||||
INSERT INTO t1( a, b )
|
||||
VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7);
|
||||
INSERT INTO t1( a, b ) VALUES
|
||||
(0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7),
|
||||
(10, 11), (11,12), (11, 14), (12, 13), (15, 10), (19, 17),
|
||||
(20, 21), (21,22), (21, 24), (22, 23), (25, 20), (29, 27);
|
||||
|
||||
INSERT INTO t2( a, b )
|
||||
VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1),
|
||||
@ -1057,9 +1067,11 @@ INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
|
||||
INSERT INTO t3
|
||||
VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0);
|
||||
INSERT INTO t3 VALUES
|
||||
(1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0),
|
||||
(11, 0), (12, 0), (13, 0), (14, 0), (15, 0),
|
||||
(16, 0), (17, 0), (18, 0), (19, 0), (20, 0);
|
||||
|
||||
# To make range scan compelling to the optimizer
|
||||
INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
@ -1071,47 +1083,47 @@ INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
# With one exception, they are independent of Problem#2.
|
||||
#
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
# Query below: Tests both Problem#1 and Problem#2 (EXPLAIN differs as well)
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
|
||||
#
|
||||
# Problem#2 Test queries.
|
||||
@ -1175,11 +1187,17 @@ CREATE TABLE t2 ( a DATETIME, KEY ( a ) );
|
||||
--echo # Make optimizer choose range scan
|
||||
INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22');
|
||||
INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23');
|
||||
INSERT INTO t1 VALUES ('2009-09-20'), ('2009-09-20'), ('2009-09-20');
|
||||
INSERT INTO t1 VALUES ('2009-09-21'), ('2009-09-21'), ('2009-09-21');
|
||||
|
||||
INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'),
|
||||
('2009-09-22 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'),
|
||||
('2009-09-23 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-20 12:00:00'), ('2009-09-20 12:00:00'),
|
||||
('2009-09-20 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-21 12:00:00'), ('2009-09-21 12:00:00'),
|
||||
('2009-09-21 12:00:00');
|
||||
|
||||
--echo # DATE vs DATE
|
||||
--replace_column 1 X 2 X 3 X 7 X 8 X 9 X 10 X
|
||||
@ -1320,7 +1338,9 @@ DROP TABLE t1;
|
||||
CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
|
||||
CREATE UNIQUE INDEX i4_uq ON t1(i4);
|
||||
|
||||
INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
|
||||
INSERT INTO t1 VALUES
|
||||
(1,10), (2,20), (3,30), (4,40), (5,50), (6,60), (7,70), (8,80);
|
||||
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
|
||||
@ -1331,8 +1351,8 @@ SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
|
||||
@ -1355,8 +1375,8 @@ SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
|
||||
@ -1479,11 +1499,15 @@ insert into t2 select a+32 from t2;
|
||||
insert into t2 select a+64 from t2;
|
||||
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
@ -2053,3 +2077,7 @@ drop table t1;
|
||||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
||||
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
@ -1,5 +1,11 @@
|
||||
set @mrr_icp_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
CREATE TABLE t1 (
|
||||
event_date date DEFAULT '0000-00-00' NOT NULL,
|
||||
type int(11) DEFAULT '0' NOT NULL,
|
||||
@ -246,7 +252,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select count(*) from t1 where x in (1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref x x 5 const 1 Using index
|
||||
explain select count(*) from t1 where x in (1,2);
|
||||
explain select count(*) from t1 where x in (1,2,3,4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index
|
||||
drop table t1;
|
||||
@ -422,19 +428,19 @@ test.t1 analyze status OK
|
||||
test.t2 analyze status Table is already up to date
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 111 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 111 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
|
||||
select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
|
||||
id name uid id name uid
|
||||
@ -717,7 +723,7 @@ WHERE
|
||||
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
|
||||
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using index condition
|
||||
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition
|
||||
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
|
||||
SELECT s.oxid FROM t1 v, t1 s
|
||||
WHERE
|
||||
@ -894,12 +900,13 @@ INSERT INTO t1 VALUES
|
||||
(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
|
||||
(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
|
||||
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
|
||||
INSERT INTO t1(status) SELECT status FROM t1;
|
||||
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using index condition; Rowid-ordered scan
|
||||
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -910,6 +917,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
SELECT * FROM t1 WHERE status NOT IN ('A','B');
|
||||
id status
|
||||
53 C
|
||||
@ -920,18 +935,26 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using where; Using index
|
||||
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
|
||||
1 SIMPLE t1 range status status 23 NULL 18 Using where; Using index
|
||||
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range status status 23 NULL 17 Using index condition; Rowid-ordered scan
|
||||
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range status status 23 NULL 17 Using index condition; Using where; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -942,6 +965,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
|
||||
id status
|
||||
53 C
|
||||
@ -952,6 +983,14 @@ id status
|
||||
58 C
|
||||
59 C
|
||||
60 C
|
||||
113 C
|
||||
114 C
|
||||
115 C
|
||||
116 C
|
||||
117 C
|
||||
118 C
|
||||
119 C
|
||||
120 C
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, primary key(a,b));
|
||||
INSERT INTO t1 VALUES
|
||||
@ -959,16 +998,16 @@ INSERT INTO t1 VALUES
|
||||
CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
|
||||
EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
|
||||
SELECT a,b FROM t1 WHERE a < 2 and b=3;
|
||||
a b
|
||||
1 3
|
||||
@ -1008,10 +1047,10 @@ INSERT INTO `t1` VALUES
|
||||
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
|
||||
explain select * from t1 where a in (3,4) and b in (1,2,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
explain select * from v1 where a in (3,4) and b in (1,2,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
|
||||
@ -1067,10 +1106,10 @@ id b c
|
||||
0 3 4
|
||||
EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using index condition; Using where; Rowid-ordered scan
|
||||
EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
|
||||
id b c
|
||||
0 3 4
|
||||
@ -1081,10 +1120,10 @@ id b c
|
||||
0 3 4
|
||||
EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 Using sort_union(idx1,idx2); Using where
|
||||
EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
|
||||
1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 Using sort_union(idx1,idx2); Using where
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
item char(20) NOT NULL default '',
|
||||
@ -1099,7 +1138,7 @@ INSERT INTO t1 VALUES
|
||||
('A2','2005-12-01 08:00:00',1000);
|
||||
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using index condition
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 3 Using index condition
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
item started price
|
||||
Warnings:
|
||||
@ -1143,7 +1182,7 @@ CREATE TABLE t1 (
|
||||
a varchar(32), index (a)
|
||||
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
|
||||
INSERT INTO t1 VALUES
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
|
||||
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'), ('C'), ('A');
|
||||
SELECT a FROM t1 WHERE a='b' OR a='B';
|
||||
a
|
||||
B
|
||||
@ -1203,13 +1242,15 @@ Z
|
||||
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
|
||||
explain select * from t2 where a=1000 and b<11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref a a 5 const 502 Using index condition
|
||||
1 SIMPLE t2 ref a a 5 const 503 Using index condition
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1( a INT, b INT, KEY( a, b ) );
|
||||
CREATE TABLE t2( a INT, b INT, KEY( a, b ) );
|
||||
CREATE TABLE t3( a INT, b INT, KEY( a, b ) );
|
||||
INSERT INTO t1( a, b )
|
||||
VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7);
|
||||
INSERT INTO t1( a, b ) VALUES
|
||||
(0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7),
|
||||
(10, 11), (11,12), (11, 14), (12, 13), (15, 10), (19, 17),
|
||||
(20, 21), (21,22), (21, 24), (22, 23), (25, 20), (29, 27);
|
||||
INSERT INTO t2( a, b )
|
||||
VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1),
|
||||
( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1),
|
||||
@ -1220,65 +1261,67 @@ INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t2 SELECT -1, -1 FROM t2;
|
||||
INSERT INTO t3
|
||||
VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0);
|
||||
INSERT INTO t3 VALUES
|
||||
(1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
|
||||
(6, 0), (7, 0), (8, 0), (9, 0), (10, 0),
|
||||
(11, 0), (12, 0), (13, 0), (14, 0), (15, 0),
|
||||
(16, 0), (17, 0), (18, 0), (19, 0), (20, 0);
|
||||
INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 < a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a < 25 OR
|
||||
25 < a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
23 <= a AND a < 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a < 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
25 <= a AND b = 23 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
25 20
|
||||
29 27
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
5 <= a AND b = 3 OR
|
||||
3 <= a;
|
||||
23 <= a AND a <= 25 OR
|
||||
23 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
a b
|
||||
5 0
|
||||
9 7
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
3 <= a AND a <= 5 OR
|
||||
3 <= a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
|
||||
SELECT * FROM t2 WHERE
|
||||
5 <= a AND a < 10 AND b = 1 OR
|
||||
15 <= a AND a < 20 AND b = 3
|
||||
@ -1317,7 +1360,7 @@ SELECT * FROM t2 WHERE
|
||||
OR
|
||||
1 <= a AND b = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 10 NULL 50 Using where; Using index
|
||||
1 SIMPLE t2 range a a 10 NULL 49 Using where; Using index
|
||||
SELECT * FROM t2 WHERE
|
||||
5 <= a AND a < 10 AND b = 2 OR
|
||||
15 <= a AND a < 20 AND b = 3
|
||||
@ -1361,7 +1404,7 @@ SELECT * FROM t2 WHERE
|
||||
OR
|
||||
1 <= a AND b = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 10 NULL 50 Using where; Using index
|
||||
1 SIMPLE t2 range a a 10 NULL 49 Using where; Using index
|
||||
SELECT * FROM t3 WHERE
|
||||
5 <= a AND a < 10 AND b = 3 OR
|
||||
a < 5 OR
|
||||
@ -1382,7 +1425,7 @@ SELECT * FROM t3 WHERE
|
||||
a < 5 OR
|
||||
a < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range a a 5 NULL 8 Using where; Using index
|
||||
1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
|
||||
@ -1400,10 +1443,16 @@ CREATE TABLE t2 ( a DATETIME, KEY ( a ) );
|
||||
# Make optimizer choose range scan
|
||||
INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22');
|
||||
INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23');
|
||||
INSERT INTO t1 VALUES ('2009-09-20'), ('2009-09-20'), ('2009-09-20');
|
||||
INSERT INTO t1 VALUES ('2009-09-21'), ('2009-09-21'), ('2009-09-21');
|
||||
INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'),
|
||||
('2009-09-22 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'),
|
||||
('2009-09-23 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-20 12:00:00'), ('2009-09-20 12:00:00'),
|
||||
('2009-09-20 12:00:00');
|
||||
INSERT INTO t2 VALUES ('2009-09-21 12:00:00'), ('2009-09-21 12:00:00'),
|
||||
('2009-09-21 12:00:00');
|
||||
# DATE vs DATE
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE a >= '2009/09/23';
|
||||
@ -1658,7 +1707,8 @@ DROP TABLE t1;
|
||||
#
|
||||
CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
|
||||
CREATE UNIQUE INDEX i4_uq ON t1(i4);
|
||||
INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
|
||||
INSERT INTO t1 VALUES
|
||||
(1,10), (2,20), (3,30), (4,40), (5,50), (6,60), (7,70), (8,80);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1674,14 +1724,13 @@ SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
|
||||
pk i4
|
||||
1 10
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 3 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE 70 BETWEEN 70 AND i4;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1692,12 +1741,17 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
4 40
|
||||
5 50
|
||||
6 60
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1717,14 +1771,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
|
||||
pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 70 AND 99999999999999999;
|
||||
pk i4
|
||||
1 10
|
||||
2 20
|
||||
3 30
|
||||
7 70
|
||||
8 80
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -1734,7 +1787,7 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 1 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
|
||||
pk i4
|
||||
1 10
|
||||
@ -1742,14 +1795,14 @@ pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 8
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
|
||||
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
|
||||
pk i4 pk i4
|
||||
EXPLAIN
|
||||
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL i4_uq NULL NULL NULL 8
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
|
||||
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
|
||||
pk i4 pk i4
|
||||
@ -1895,19 +1948,23 @@ insert into t2 select a+16 from t2;
|
||||
insert into t2 select a+32 from t2;
|
||||
insert into t2 select a+64 from t2;
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 64
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < 1000;
|
||||
count(*)
|
||||
128
|
||||
832
|
||||
explain
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 64
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
|
||||
1 SIMPLE t1 range i1,i2 i1 4 NULL 12 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
|
||||
select count(*) from t2 left join t1
|
||||
on (t1.key1 < 3 or t1.key1 between 920 and 930) and t1.key2 < t2.a;
|
||||
count(*)
|
||||
126
|
||||
drop table t1,t2;
|
||||
@ -1921,7 +1978,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1);
|
||||
explain
|
||||
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index
|
||||
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
|
||||
a b c
|
||||
2 2 0
|
||||
@ -1951,7 +2008,7 @@ INSERT INTO t100(I,J) VALUES(8,26);
|
||||
|
||||
EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t100 range I I 10 NULL 4 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t100 range I I 10 NULL 3 Using index condition; Using where; Rowid-ordered scan
|
||||
|
||||
SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
|
||||
K I J
|
||||
@ -2274,10 +2331,10 @@ CREATE TABLE t1 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t1 (a) VALUES (10),(10),(10),(10),(10),(10),(10),(10),(10),(10),(70);
|
||||
EXPLAIN SELECT * FROM t1 WHERE a<>10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using index condition; Rowid-ordered scan
|
||||
EXPLAIN SELECT * FROM t1 WHERE 10<>a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 3 Using index condition; Rowid-ordered scan
|
||||
1 SIMPLE t1 range a a 5 NULL 2 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE a<>10;
|
||||
a b
|
||||
70 NULL
|
||||
@ -2335,7 +2392,7 @@ insert into t1 values
|
||||
# range access to t1 by 2-component keys for index idx
|
||||
explain select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 10 NULL 7 Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range idx idx 10 NULL 6 Using where; Rowid-ordered scan
|
||||
explain format=json select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7));
|
||||
EXPLAIN
|
||||
{
|
||||
@ -2348,7 +2405,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "10",
|
||||
"used_key_parts": ["a", "b"],
|
||||
"rows": 7,
|
||||
"rows": 6,
|
||||
"filtered": 100,
|
||||
"attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))",
|
||||
"mrr_type": "Rowid-ordered scan"
|
||||
@ -2633,7 +2690,7 @@ insert into t1 select * from t1;
|
||||
explain select * from t1,t2
|
||||
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range idx1,idx2 idx2 5 NULL 6 Using where; Rowid-ordered scan
|
||||
1 SIMPLE t2 range idx1,idx2 idx1 5 NULL 7 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 ref idx idx 5 test.t2.d 11
|
||||
explain format=json select * from t1,t2
|
||||
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
|
||||
@ -2645,12 +2702,13 @@ EXPLAIN
|
||||
"table_name": "t2",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["idx1", "idx2"],
|
||||
"key": "idx2",
|
||||
"key": "idx1",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["e"],
|
||||
"rows": 6,
|
||||
"used_key_parts": ["d"],
|
||||
"rows": 7,
|
||||
"filtered": 100,
|
||||
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1 and t2.d is not null",
|
||||
"index_condition": "t2.d is not null",
|
||||
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1",
|
||||
"mrr_type": "Rowid-ordered scan"
|
||||
},
|
||||
"table": {
|
||||
@ -2838,7 +2896,7 @@ explain select * from t1,t2
|
||||
where a = d and (a,2) in ((2,2),(7,7),(8,8)) and
|
||||
length(c) = 1 and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 5 NULL 13 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range idx idx 5 NULL 12 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref idx3 idx3 5 test.t1.a 3 Using where
|
||||
explain format=json select * from t1,t2
|
||||
where a = d and (a,2) in ((2,2),(7,7),(8,8)) and
|
||||
@ -2854,7 +2912,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 13,
|
||||
"rows": 12,
|
||||
"filtered": 100,
|
||||
"index_condition": "t1.a is not null",
|
||||
"attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1",
|
||||
@ -2915,7 +2973,7 @@ where id = 1 and a = d and
|
||||
length(c) = 1 and length(f) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1
|
||||
1 SIMPLE t1 range idx idx 5 NULL 13 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t1 range idx idx 5 NULL 12 Using index condition; Using where; Rowid-ordered scan
|
||||
1 SIMPLE t2 ref idx3 idx3 5 test.t1.a 3 Using where
|
||||
explain format=json select * from t1,t2,t3
|
||||
where id = 1 and a = d and
|
||||
@ -2943,7 +3001,7 @@ EXPLAIN
|
||||
"key": "idx",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["a"],
|
||||
"rows": 13,
|
||||
"rows": 12,
|
||||
"filtered": 100,
|
||||
"index_condition": "t1.a is not null",
|
||||
"attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1",
|
||||
@ -3036,4 +3094,7 @@ drop table t1;
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
set optimizer_switch=@mrr_icp_extra_tmp;
|
||||
|
@ -1,5 +1,6 @@
|
||||
set @mrr_icp_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
|
||||
--source range.test
|
||||
|
||||
|
@ -64,7 +64,7 @@ Country IN ('CAN', 'ARG') AND ID BETWEEN 120 AND 130 OR
|
||||
Country <= 'ALB' AND Name LIKE 'L%' OR
|
||||
ID BETWEEN 3807 AND 3810;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,PRIMARY,Country 35,4,3 NULL 31 Using sort_union(Name,PRIMARY,Country); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,PRIMARY,Country 35,4,3 NULL 30 Using sort_union(Name,PRIMARY,Country); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE (Population > 101000 AND Population < 115000);
|
||||
@ -175,7 +175,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE (Name < 'Bb');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Name Name 35 NULL 208 Using index condition
|
||||
1 SIMPLE City range Name Name 35 NULL 207 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE (Country > 'A' AND Country < 'B');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -327,11 +327,11 @@ ID Name Country Population
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE (ID < 10) OR (ID BETWEEN 100 AND 110);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range PRIMARY PRIMARY 4 NULL 21 Using index condition; Using where
|
||||
1 SIMPLE City range PRIMARY PRIMARY 4 NULL 20 Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE (ID < 200) OR (ID BETWEEN 100 AND 200);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range PRIMARY PRIMARY 4 NULL 201 Using index condition; Using where
|
||||
1 SIMPLE City range PRIMARY PRIMARY 4 NULL 200 Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE (ID < 600) OR (ID BETWEEN 900 AND 1500);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -339,11 +339,11 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Country > 'A' AND Country < 'ARG';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country Country 3 NULL 19 Using index condition
|
||||
1 SIMPLE City range Country Country 3 NULL 20 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Name LIKE 'H%' OR Name LIKE 'P%' ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Name Name 35 NULL 222 Using index condition; Using where
|
||||
1 SIMPLE City range Name Name 35 NULL 223 Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Name LIKE 'Ha%' OR Name LIKE 'Pa%' ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -354,21 +354,21 @@ WHERE ((ID < 10) AND (Name LIKE 'H%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 110) AND
|
||||
(Name LIKE 'P%' OR (Population > 103000 AND Population < 104000)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL 21 Using index condition; Using where
|
||||
1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL 20 Using index condition; Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 800) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 900 AND 1500) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 105000)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 35,3,4 NULL 128 Using sort_union(Name,Country,Population); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 35,3,4 NULL 151 Using sort_union(Name,Country,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 200) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103200 AND Population < 104000)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 35,3,4 NULL 128 Using sort_union(Name,Country,Population); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 35,3,4 NULL 124 Using sort_union(Name,Country,Population); Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ((ID < 10) AND (Name LIKE 'H%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 110) AND
|
||||
@ -584,11 +584,11 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Country < 'C';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country Country 3 NULL 436 Using index condition
|
||||
1 SIMPLE City range Country Country 3 NULL 435 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Country < 'AGO';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country Country 3 NULL 6 Using index condition
|
||||
1 SIMPLE City range Country Country 3 NULL 5 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Name BETWEEN 'P' AND 'S';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -616,7 +616,7 @@ WHERE ((Population > 101000 AND Population < 102000) AND
|
||||
((ID BETWEEN 3400 AND 3800) AND
|
||||
(Country < 'AGO' OR Name LIKE 'Pa%'));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,Population 3,35,4 NULL 84 Using sort_union(Country,Name,Population); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,Population 3,35,4 NULL 83 Using sort_union(Country,Name,Population); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Population > 101000 AND Population < 110000) AND
|
||||
@ -624,7 +624,7 @@ WHERE ((Population > 101000 AND Population < 110000) AND
|
||||
((ID BETWEEN 3790 AND 3800) AND
|
||||
(Country < 'C' OR Name LIKE 'P%'));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,PRIMARY 3,35,4 NULL 56 Using sort_union(Country,Name,PRIMARY); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,PRIMARY 3,35,4 NULL 55 Using sort_union(Country,Name,PRIMARY); Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ((Population > 101000 AND Population < 102000) AND
|
||||
(Country < 'C' OR Name BETWEEN 'P' AND 'S')) OR
|
||||
@ -679,7 +679,7 @@ CREATE INDEX CountryPopulation ON City(Country,Population);
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Name LIKE 'Pas%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Name Name 35 NULL 5 Using index condition
|
||||
1 SIMPLE City range Name Name 35 NULL 4 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Name LIKE 'P%';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
@ -695,19 +695,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN
|
||||
SELECT * FROM City WHERE Country='FIN';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City ref Country,CountryPopulation Country 3 const 6 Using index condition
|
||||
1 SIMPLE City ref Country,CountryPopulation Country 3 const 7 Using index condition
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Population > 101000 AND Population < 103000) OR Name LIKE 'Pas%')
|
||||
AND Country='USA';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Population,Country,Name,CountryPopulation CountryPopulation,Name 7,35 NULL 15 Using sort_union(CountryPopulation,Name); Using where
|
||||
1 SIMPLE City index_merge Population,Country,Name,CountryPopulation CountryPopulation,Name 7,35 NULL 14 Using sort_union(CountryPopulation,Name); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Population > 101000 AND Population < 103000) OR Name LIKE 'P%')
|
||||
AND Country='FIN';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City ref Population,Country,Name,CountryPopulation Country 3 const 6 Using index condition; Using where
|
||||
1 SIMPLE City ref Population,Country,Name,CountryPopulation Country 3 const 7 Using index condition; Using where
|
||||
SELECT * FROM City
|
||||
WHERE ((Population > 101000 AND Population < 103000) OR Name LIKE 'Pas%')
|
||||
AND Country='USA';
|
||||
@ -1166,7 +1166,7 @@ EXPLAIN SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Samara' AND Country='RUS') OR
|
||||
(Name='Seattle' AND Country='USA');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 29 Using index condition; Using where
|
||||
1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 28 Using index condition; Using where
|
||||
SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Manila' AND Country='PHL') OR
|
||||
(Name='Addis Abeba' AND Country='ETH') OR
|
||||
@ -1620,7 +1620,7 @@ SELECT COUNT(*) FROM t1
|
||||
WHERE c = 'i' OR b IN ( 'Arkansas' , 'd' , 'pdib' , 'can' ) OR
|
||||
(pk BETWEEN 120 AND 79 + 255 OR a IN ( 4 , 179 , 1 ) ) AND a > 8 ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2,idx3 idx3,idx2,PRIMARY,idx1 67,13,4,3 NULL 8 Using sort_union(idx3,idx2,PRIMARY,idx1); Using where
|
||||
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2,idx3 idx3,idx2,PRIMARY,idx1 67,13,4,3 NULL 9 Using sort_union(idx3,idx2,PRIMARY,idx1); Using where
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
f1 int, f2 int, f3 int, f4 int, f5 int,
|
||||
@ -1659,7 +1659,7 @@ SELECT * FROM t1 FORCE KEY (PRIMARY,f3,f4)
|
||||
WHERE ( f3 = 1 OR f1 = 7 ) AND f1 < 10
|
||||
OR f3 BETWEEN 2 AND 2 AND ( f3 = 1 OR f4 != 1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY,f3,f4 NULL NULL NULL 2 Using where
|
||||
1 SIMPLE t1 index_merge PRIMARY,f3,f4 f3,PRIMARY,f3 5,4,5 NULL 3 Using union(f3,PRIMARY,f3); Using where
|
||||
SELECT * FROM t1 FORCE KEY (PRIMARY,f3,f4)
|
||||
WHERE ( f3 = 1 OR f1 = 7 ) AND f1 < 10
|
||||
OR f3 BETWEEN 2 AND 2 AND ( f3 = 1 OR f4 != 1 );
|
||||
@ -1713,6 +1713,9 @@ PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c)
|
||||
INSERT INTO t1 VALUES
|
||||
(0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3),
|
||||
(0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SET SESSION optimizer_switch='index_merge_sort_union=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
@ -1762,7 +1765,7 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a BETWEEN 4 AND 5 AND b IN (255,4) OR a IN (2,14,25) OR a!=2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY,idx NULL NULL NULL 2 Using where
|
||||
1 SIMPLE t1 range PRIMARY,idx PRIMARY 0 NULL 2 Using index condition; Using where
|
||||
SELECT * FROM t1
|
||||
WHERE a BETWEEN 4 AND 5 AND b IN (255,4) OR a IN (2,14,25) OR a!=2;
|
||||
a b
|
||||
@ -1790,12 +1793,15 @@ INSERT INTO t1 VALUES
|
||||
(7,'Pennsylvania','Harrisburg'),
|
||||
(8,'Virginia','Richmond')
|
||||
;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 FORCE KEY (state,capital)
|
||||
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
|
||||
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range state,capital state 71 NULL 12 Using index condition; Using where
|
||||
1 SIMPLE t1 range state,capital state 71 NULL 8 Using index condition; Using where
|
||||
SELECT * FROM t1 FORCE KEY (state,capital)
|
||||
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
|
||||
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
|
||||
@ -1886,6 +1892,6 @@ Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR
|
||||
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
|
||||
Country='ITA' AND Name IN ('Napoli', 'Venezia');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range CountryName,Name CountryName 38 NULL 22 Using index condition; Using where
|
||||
1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition; Using where
|
||||
DROP DATABASE world;
|
||||
set session optimizer_switch='index_merge_sort_intersection=default';
|
||||
|
@ -229,13 +229,13 @@ EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 800) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 900 AND 1500) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 105000)));
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 200) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103200 AND Population < 104000)));
|
||||
|
||||
|
||||
# The following 6 queries check that the plans
|
||||
@ -1158,6 +1158,8 @@ INSERT INTO t1 VALUES
|
||||
(0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3),
|
||||
(0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3);
|
||||
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
SET SESSION optimizer_switch='index_merge_sort_union=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
@ -1231,6 +1233,8 @@ INSERT INTO t1 VALUES
|
||||
(8,'Virginia','Richmond')
|
||||
;
|
||||
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 FORCE KEY (state,capital)
|
||||
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
|
||||
|
@ -1,4 +1,9 @@
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4;
|
||||
DROP DATABASE IF EXISTS world;
|
||||
set names utf8;
|
||||
@ -360,16 +365,16 @@ EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 800) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 900 AND 1500) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 105000)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,PRIMARY 39,3,4 NULL 683 Using sort_union(Name,Country,PRIMARY); Using where
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 200) AND
|
||||
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
|
||||
(Name LIKE 'Pa%' OR (Population > 103200 AND Population < 104000)));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Population,PRIMARY 39,4,4 NULL 307 Using sort_union(Name,Population,PRIMARY); Using where
|
||||
1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Population,PRIMARY 39,4,4 NULL 302 Using sort_union(Name,Population,PRIMARY); Using where
|
||||
SELECT * FROM City USE INDEX ()
|
||||
WHERE ((ID < 10) AND (Name LIKE 'H%' OR (Country > 'A' AND Country < 'ARG')))
|
||||
OR ((ID BETWEEN 100 AND 110) AND
|
||||
@ -1080,7 +1085,7 @@ EXPLAIN SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Samara' AND Country='RUS') OR
|
||||
(Name='Seattle' AND Country='USA');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 27 Using index condition; Using where
|
||||
1 SIMPLE City index_merge Country,CountryPopulation,CountryName,CityName CountryName,CityName 38,35 NULL 27 Using sort_union(CountryName,CityName); Using where
|
||||
SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Manila' AND Country='PHL') OR
|
||||
(Name='Addis Abeba' AND Country='ETH') OR
|
||||
@ -1110,33 +1115,33 @@ SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Samara' AND Country='RUS') OR
|
||||
(Name='Seattle' AND Country='USA');
|
||||
Name Country Population
|
||||
Toronto CAN 688275
|
||||
Vancouver CAN 514008
|
||||
Basel CHE 166700
|
||||
Peking CHN 7472000
|
||||
Praha CZE 1181126
|
||||
Dresden DEU 476668
|
||||
Addis Abeba ETH 2495000
|
||||
Paris FRA 2125246
|
||||
Manila PHL 1581082
|
||||
Jakarta IDN 9604900
|
||||
Bangalore IND 2660088
|
||||
Delhi IND 7206704
|
||||
Bangalore IND 2660088
|
||||
Teheran IRN 6758845
|
||||
Roma ITA 2643581
|
||||
Venezia ITA 277305
|
||||
Tokyo JPN 7980230
|
||||
Toronto CAN 688275
|
||||
Vancouver CAN 514008
|
||||
Peking CHN 7472000
|
||||
Seoul KOR 9981619
|
||||
Kaunas LTU 412639
|
||||
Rabat MAR 623457
|
||||
Tijuana MEX 1212232
|
||||
Lagos NGA 1518000
|
||||
Manila PHL 1581082
|
||||
Samara RUS 1156100
|
||||
Paris FRA 2125246
|
||||
Dresden DEU 476668
|
||||
Dakar SEN 785071
|
||||
Basel CHE 166700
|
||||
Praha CZE 1181126
|
||||
Ankara TUR 3038159
|
||||
Lugansk UKR 469000
|
||||
Seattle USA 563374
|
||||
Caracas VEN 1975294
|
||||
Samara RUS 1156100
|
||||
Seattle USA 563374
|
||||
set optimizer_switch='index_merge=off';
|
||||
EXPLAIN SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Manila' AND Country='PHL') OR
|
||||
@ -1167,7 +1172,7 @@ EXPLAIN SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Samara' AND Country='RUS') OR
|
||||
(Name='Seattle' AND Country='USA');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 27 Using index condition; Using where
|
||||
1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CityName 35 NULL 28 Using index condition; Using where
|
||||
SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Manila' AND Country='PHL') OR
|
||||
(Name='Addis Abeba' AND Country='ETH') OR
|
||||
@ -1197,33 +1202,33 @@ SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Samara' AND Country='RUS') OR
|
||||
(Name='Seattle' AND Country='USA');
|
||||
Name Country Population
|
||||
Toronto CAN 688275
|
||||
Vancouver CAN 514008
|
||||
Addis Abeba ETH 2495000
|
||||
Ankara TUR 3038159
|
||||
Bangalore IND 2660088
|
||||
Basel CHE 166700
|
||||
Caracas VEN 1975294
|
||||
Dakar SEN 785071
|
||||
Delhi IND 7206704
|
||||
Dresden DEU 476668
|
||||
Jakarta IDN 9604900
|
||||
Kaunas LTU 412639
|
||||
Lagos NGA 1518000
|
||||
Lugansk UKR 469000
|
||||
Manila PHL 1581082
|
||||
Paris FRA 2125246
|
||||
Peking CHN 7472000
|
||||
Praha CZE 1181126
|
||||
Dresden DEU 476668
|
||||
Addis Abeba ETH 2495000
|
||||
Paris FRA 2125246
|
||||
Jakarta IDN 9604900
|
||||
Bangalore IND 2660088
|
||||
Delhi IND 7206704
|
||||
Teheran IRN 6758845
|
||||
Roma ITA 2643581
|
||||
Venezia ITA 277305
|
||||
Tokyo JPN 7980230
|
||||
Seoul KOR 9981619
|
||||
Kaunas LTU 412639
|
||||
Rabat MAR 623457
|
||||
Tijuana MEX 1212232
|
||||
Lagos NGA 1518000
|
||||
Manila PHL 1581082
|
||||
Roma ITA 2643581
|
||||
Samara RUS 1156100
|
||||
Dakar SEN 785071
|
||||
Ankara TUR 3038159
|
||||
Lugansk UKR 469000
|
||||
Seattle USA 563374
|
||||
Caracas VEN 1975294
|
||||
Seoul KOR 9981619
|
||||
Teheran IRN 6758845
|
||||
Tijuana MEX 1212232
|
||||
Tokyo JPN 7980230
|
||||
Toronto CAN 688275
|
||||
Vancouver CAN 514008
|
||||
Venezia ITA 277305
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n
|
||||
@ -1714,6 +1719,9 @@ PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c)
|
||||
INSERT INTO t1 VALUES
|
||||
(0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3),
|
||||
(0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SET SESSION optimizer_switch='index_merge_sort_union=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
@ -1751,7 +1759,7 @@ SELECT * FROM t1
|
||||
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
|
||||
(t1.c=0 OR t1.a=500);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY,idx PRIMARY 4 NULL 1 Using where
|
||||
1 SIMPLE t1 index PRIMARY,idx idx 10 NULL 2 Using where; Using index
|
||||
SELECT * FROM t1
|
||||
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
|
||||
(t1.c=0 OR t1.a=500);
|
||||
@ -1791,12 +1799,15 @@ INSERT INTO t1 VALUES
|
||||
(7,'Pennsylvania','Harrisburg'),
|
||||
(8,'Virginia','Richmond')
|
||||
;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 FORCE KEY (state,capital)
|
||||
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
|
||||
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range state,capital state 71 NULL 12 Using index condition; Using where
|
||||
1 SIMPLE t1 range state,capital state 71 NULL 8 Using index condition; Using where
|
||||
SELECT * FROM t1 FORCE KEY (state,capital)
|
||||
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
|
||||
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
|
||||
@ -1890,4 +1901,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition; Using where
|
||||
DROP DATABASE world;
|
||||
set session optimizer_switch='index_merge_sort_intersection=default';
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
@ -2,6 +2,15 @@
|
||||
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
|
||||
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
|
||||
set @innodb_stats_persistent_sample_pages_save=
|
||||
@@innodb_stats_persistent_sample_pages;
|
||||
|
||||
set global innodb_stats_persistent= 1;
|
||||
set global innodb_stats_persistent_sample_pages=100;
|
||||
--source range_vs_index_merge.test
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
set global innodb_stats_persistent_sample_pages=
|
||||
@innodb_stats_persistent_sample_pages_save;
|
||||
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
716
mysql-test/main/rowid_filter.result
Normal file
716
mysql-test/main/rowid_filter.result
Normal file
@ -0,0 +1,716 @@
|
||||
DROP DATABASE IF EXISTS dbt3_s001;
|
||||
CREATE DATABASE dbt3_s001;
|
||||
use dbt3_s001;
|
||||
CREATE INDEX i_l_quantity ON lineitem(l_quantity);
|
||||
CREATE INDEX i_o_totalprice ON orders(o_totalprice);
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@use_stat_tables=preferably;
|
||||
ANALYZE TABLE lineitem, orders;
|
||||
show create table lineitem;
|
||||
Table Create Table
|
||||
lineitem CREATE TABLE `lineitem` (
|
||||
`l_orderkey` int(11) NOT NULL DEFAULT 0,
|
||||
`l_partkey` int(11) DEFAULT NULL,
|
||||
`l_suppkey` int(11) DEFAULT NULL,
|
||||
`l_linenumber` int(11) NOT NULL DEFAULT 0,
|
||||
`l_quantity` double DEFAULT NULL,
|
||||
`l_extendedprice` double DEFAULT NULL,
|
||||
`l_discount` double DEFAULT NULL,
|
||||
`l_tax` double DEFAULT NULL,
|
||||
`l_returnflag` char(1) DEFAULT NULL,
|
||||
`l_linestatus` char(1) DEFAULT NULL,
|
||||
`l_shipDATE` date DEFAULT NULL,
|
||||
`l_commitDATE` date DEFAULT NULL,
|
||||
`l_receiptDATE` date DEFAULT NULL,
|
||||
`l_shipinstruct` char(25) DEFAULT NULL,
|
||||
`l_shipmode` char(10) DEFAULT NULL,
|
||||
`l_comment` varchar(44) DEFAULT NULL,
|
||||
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
|
||||
KEY `i_l_shipdate` (`l_shipDATE`),
|
||||
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
|
||||
KEY `i_l_partkey` (`l_partkey`),
|
||||
KEY `i_l_suppkey` (`l_suppkey`),
|
||||
KEY `i_l_receiptdate` (`l_receiptDATE`),
|
||||
KEY `i_l_orderkey` (`l_orderkey`),
|
||||
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
|
||||
KEY `i_l_commitdate` (`l_commitDATE`),
|
||||
KEY `i_l_quantity` (`l_quantity`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show create table orders;
|
||||
Table Create Table
|
||||
orders CREATE TABLE `orders` (
|
||||
`o_orderkey` int(11) NOT NULL,
|
||||
`o_custkey` int(11) DEFAULT NULL,
|
||||
`o_orderstatus` char(1) DEFAULT NULL,
|
||||
`o_totalprice` double DEFAULT NULL,
|
||||
`o_orderDATE` date DEFAULT NULL,
|
||||
`o_orderpriority` char(15) DEFAULT NULL,
|
||||
`o_clerk` char(15) DEFAULT NULL,
|
||||
`o_shippriority` int(11) DEFAULT NULL,
|
||||
`o_comment` varchar(79) DEFAULT NULL,
|
||||
PRIMARY KEY (`o_orderkey`),
|
||||
KEY `i_o_orderdate` (`o_orderDATE`),
|
||||
KEY `i_o_custkey` (`o_custkey`),
|
||||
KEY `i_o_totalprice` (`o_totalprice`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
set optimizer_use_condition_selectivity=2;
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (11%) Using index condition; Using where; Using filter
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["i_l_shipdate", "i_l_quantity"],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_l_quantity",
|
||||
"used_key_parts": ["l_quantity"]
|
||||
},
|
||||
"rows": 662,
|
||||
"selectivity_pct": 11.024
|
||||
},
|
||||
"rows": 509,
|
||||
"filtered": 11.024,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
l_orderkey l_linenumber l_shipdate l_quantity
|
||||
1121 5 1997-04-27 47
|
||||
1121 6 1997-04-21 50
|
||||
1441 7 1997-06-07 50
|
||||
1443 1 1997-02-05 47
|
||||
1473 1 1997-05-05 50
|
||||
1568 2 1997-04-06 46
|
||||
1632 1 1997-01-25 47
|
||||
1632 3 1997-01-29 47
|
||||
1954 7 1997-06-04 49
|
||||
1959 1 1997-05-05 46
|
||||
2151 3 1997-01-20 49
|
||||
2177 5 1997-05-10 46
|
||||
2369 2 1997-01-02 47
|
||||
2469 3 1997-01-11 48
|
||||
2469 6 1997-03-03 49
|
||||
2470 2 1997-06-02 50
|
||||
260 1 1997-03-24 50
|
||||
288 2 1997-04-19 49
|
||||
289 4 1997-03-14 48
|
||||
3009 1 1997-03-19 48
|
||||
3105 3 1997-02-28 48
|
||||
3106 2 1997-02-27 49
|
||||
3429 1 1997-04-08 48
|
||||
3490 2 1997-06-27 50
|
||||
3619 1 1997-01-22 49
|
||||
3619 3 1997-01-31 46
|
||||
3969 3 1997-05-29 46
|
||||
4005 4 1997-01-31 49
|
||||
4036 1 1997-06-21 46
|
||||
4066 4 1997-02-17 49
|
||||
4098 1 1997-01-26 46
|
||||
422 3 1997-06-21 46
|
||||
4258 3 1997-01-02 46
|
||||
4421 2 1997-04-21 46
|
||||
4421 3 1997-05-25 46
|
||||
4453 3 1997-05-29 48
|
||||
4484 7 1997-03-17 50
|
||||
4609 3 1997-02-11 46
|
||||
484 1 1997-03-06 49
|
||||
484 3 1997-01-24 50
|
||||
484 5 1997-03-05 48
|
||||
485 1 1997-03-28 50
|
||||
4868 1 1997-04-29 47
|
||||
4868 3 1997-04-23 49
|
||||
4934 1 1997-05-20 48
|
||||
4967 1 1997-05-27 50
|
||||
5090 2 1997-04-05 46
|
||||
5152 2 1997-03-10 50
|
||||
5158 4 1997-04-10 49
|
||||
5606 3 1997-03-11 46
|
||||
5606 7 1997-02-01 46
|
||||
5762 4 1997-03-02 47
|
||||
581 3 1997-02-27 49
|
||||
5829 5 1997-01-31 49
|
||||
5831 4 1997-02-24 46
|
||||
5895 2 1997-04-27 47
|
||||
5895 3 1997-03-15 49
|
||||
5952 1 1997-06-30 49
|
||||
705 1 1997-04-18 46
|
||||
836 3 1997-03-21 46
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["i_l_shipdate", "i_l_quantity"],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 509,
|
||||
"filtered": 11.024,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
l_orderkey l_linenumber l_shipdate l_quantity
|
||||
1121 5 1997-04-27 47
|
||||
1121 6 1997-04-21 50
|
||||
1441 7 1997-06-07 50
|
||||
1443 1 1997-02-05 47
|
||||
1473 1 1997-05-05 50
|
||||
1568 2 1997-04-06 46
|
||||
1632 1 1997-01-25 47
|
||||
1632 3 1997-01-29 47
|
||||
1954 7 1997-06-04 49
|
||||
1959 1 1997-05-05 46
|
||||
2151 3 1997-01-20 49
|
||||
2177 5 1997-05-10 46
|
||||
2369 2 1997-01-02 47
|
||||
2469 3 1997-01-11 48
|
||||
2469 6 1997-03-03 49
|
||||
2470 2 1997-06-02 50
|
||||
260 1 1997-03-24 50
|
||||
288 2 1997-04-19 49
|
||||
289 4 1997-03-14 48
|
||||
3009 1 1997-03-19 48
|
||||
3105 3 1997-02-28 48
|
||||
3106 2 1997-02-27 49
|
||||
3429 1 1997-04-08 48
|
||||
3490 2 1997-06-27 50
|
||||
3619 1 1997-01-22 49
|
||||
3619 3 1997-01-31 46
|
||||
3969 3 1997-05-29 46
|
||||
4005 4 1997-01-31 49
|
||||
4036 1 1997-06-21 46
|
||||
4066 4 1997-02-17 49
|
||||
4098 1 1997-01-26 46
|
||||
422 3 1997-06-21 46
|
||||
4258 3 1997-01-02 46
|
||||
4421 2 1997-04-21 46
|
||||
4421 3 1997-05-25 46
|
||||
4453 3 1997-05-29 48
|
||||
4484 7 1997-03-17 50
|
||||
4609 3 1997-02-11 46
|
||||
484 1 1997-03-06 49
|
||||
484 3 1997-01-24 50
|
||||
484 5 1997-03-05 48
|
||||
485 1 1997-03-28 50
|
||||
4868 1 1997-04-29 47
|
||||
4868 3 1997-04-23 49
|
||||
4934 1 1997-05-20 48
|
||||
4967 1 1997-05-27 50
|
||||
5090 2 1997-04-05 46
|
||||
5152 2 1997-03-10 50
|
||||
5158 4 1997-04-10 49
|
||||
5606 3 1997-03-11 46
|
||||
5606 7 1997-02-01 46
|
||||
5762 4 1997-03-02 47
|
||||
581 3 1997-02-27 49
|
||||
5829 5 1997-01-31 49
|
||||
5831 4 1997-02-24 46
|
||||
5895 2 1997-04-27 47
|
||||
5895 3 1997-03-15 49
|
||||
5952 1 1997-06-30 49
|
||||
705 1 1997-04-18 46
|
||||
836 3 1997-03-21 46
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using index condition
|
||||
1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (5%) Using where; Using filter
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 98,
|
||||
"filtered": 100,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_o_totalprice",
|
||||
"used_key_parts": ["o_totalprice"]
|
||||
},
|
||||
"rows": 81,
|
||||
"selectivity_pct": 5.4
|
||||
},
|
||||
"rows": 1,
|
||||
"filtered": 5.4,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
484 3 1997-01-24 219920.62
|
||||
5606 6 1997-01-11 219959.08
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using index condition
|
||||
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 98,
|
||||
"filtered": 100,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rows": 1,
|
||||
"filtered": 5.4,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
484 3 1997-01-24 219920.62
|
||||
5606 6 1997-01-11 219959.08
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (11%) Using index condition; Using where; Using filter
|
||||
1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (10%) Using where; Using filter
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity",
|
||||
"i_l_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_l_quantity",
|
||||
"used_key_parts": ["l_quantity"]
|
||||
},
|
||||
"rows": 662,
|
||||
"selectivity_pct": 11.024
|
||||
},
|
||||
"rows": 509,
|
||||
"filtered": 11.024,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_o_totalprice",
|
||||
"used_key_parts": ["o_totalprice"]
|
||||
},
|
||||
"rows": 152,
|
||||
"selectivity_pct": 10.133
|
||||
},
|
||||
"rows": 1,
|
||||
"filtered": 10.133,
|
||||
"attached_condition": "orders.o_totalprice between 180000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate l_quantity o_totalprice
|
||||
1632 1 1997-01-25 47 183286.33
|
||||
1632 3 1997-01-29 47 183286.33
|
||||
2177 5 1997-05-10 46 183493.42
|
||||
2469 3 1997-01-11 48 192074.23
|
||||
2469 6 1997-03-03 49 192074.23
|
||||
3619 1 1997-01-22 49 222274.54
|
||||
3619 3 1997-01-31 46 222274.54
|
||||
484 1 1997-03-06 49 219920.62
|
||||
484 3 1997-01-24 50 219920.62
|
||||
484 5 1997-03-05 48 219920.62
|
||||
4934 1 1997-05-20 48 180478.16
|
||||
5606 3 1997-03-11 46 219959.08
|
||||
5606 7 1997-02-01 46 219959.08
|
||||
5829 5 1997-01-31 49 183734.56
|
||||
5895 2 1997-04-27 47 201419.83
|
||||
5895 3 1997-03-15 49 201419.83
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where
|
||||
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity",
|
||||
"i_l_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 509,
|
||||
"filtered": 11.024,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rows": 1,
|
||||
"filtered": 10.133,
|
||||
"attached_condition": "orders.o_totalprice between 180000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate l_quantity o_totalprice
|
||||
1632 1 1997-01-25 47 183286.33
|
||||
1632 3 1997-01-29 47 183286.33
|
||||
2177 5 1997-05-10 46 183493.42
|
||||
2469 3 1997-01-11 48 192074.23
|
||||
2469 6 1997-03-03 49 192074.23
|
||||
3619 1 1997-01-22 49 222274.54
|
||||
3619 3 1997-01-31 46 222274.54
|
||||
484 1 1997-03-06 49 219920.62
|
||||
484 3 1997-01-24 50 219920.62
|
||||
484 5 1997-03-05 48 219920.62
|
||||
4934 1 1997-05-20 48 180478.16
|
||||
5606 3 1997-03-11 46 219959.08
|
||||
5606 7 1997-02-01 46 219959.08
|
||||
5829 5 1997-01-31 49 183734.56
|
||||
5895 2 1997-04-27 47 201419.83
|
||||
5895 3 1997-03-15 49 201419.83
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 81 Using index condition
|
||||
1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using filter
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 81,
|
||||
"filtered": 100,
|
||||
"index_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_l_shipdate",
|
||||
"used_key_parts": ["l_shipDATE"]
|
||||
},
|
||||
"rows": 509,
|
||||
"selectivity_pct": 8.4763
|
||||
},
|
||||
"rows": 4,
|
||||
"filtered": 8.4763,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
1890 1 1997-04-02 202364.58
|
||||
1890 3 1997-02-09 202364.58
|
||||
1890 4 1997-04-08 202364.58
|
||||
1890 5 1997-04-15 202364.58
|
||||
1890 6 1997-02-13 202364.58
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 4 1997-03-18 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
453 1 1997-06-30 216826.73
|
||||
453 2 1997-06-30 216826.73
|
||||
484 1 1997-03-06 219920.62
|
||||
484 2 1997-04-09 219920.62
|
||||
484 3 1997-01-24 219920.62
|
||||
484 4 1997-04-29 219920.62
|
||||
484 5 1997-03-05 219920.62
|
||||
484 6 1997-04-06 219920.62
|
||||
5606 2 1997-02-23 219959.08
|
||||
5606 3 1997-03-11 219959.08
|
||||
5606 4 1997-02-06 219959.08
|
||||
5606 6 1997-01-11 219959.08
|
||||
5606 7 1997-02-01 219959.08
|
||||
5859 2 1997-05-15 210643.96
|
||||
5859 5 1997-05-28 210643.96
|
||||
5859 6 1997-06-15 210643.96
|
||||
5895 1 1997-04-05 201419.83
|
||||
5895 2 1997-04-27 201419.83
|
||||
5895 3 1997-03-15 201419.83
|
||||
5895 4 1997-03-03 201419.83
|
||||
5895 5 1997-04-30 201419.83
|
||||
5895 6 1997-04-19 201419.83
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 81 Using index condition
|
||||
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 81,
|
||||
"filtered": 100,
|
||||
"index_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rows": 4,
|
||||
"filtered": 8.4763,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
1890 1 1997-04-02 202364.58
|
||||
1890 3 1997-02-09 202364.58
|
||||
1890 4 1997-04-08 202364.58
|
||||
1890 5 1997-04-15 202364.58
|
||||
1890 6 1997-02-13 202364.58
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 4 1997-03-18 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
453 1 1997-06-30 216826.73
|
||||
453 2 1997-06-30 216826.73
|
||||
484 1 1997-03-06 219920.62
|
||||
484 2 1997-04-09 219920.62
|
||||
484 3 1997-01-24 219920.62
|
||||
484 4 1997-04-29 219920.62
|
||||
484 5 1997-03-05 219920.62
|
||||
484 6 1997-04-06 219920.62
|
||||
5606 2 1997-02-23 219959.08
|
||||
5606 3 1997-03-11 219959.08
|
||||
5606 4 1997-02-06 219959.08
|
||||
5606 6 1997-01-11 219959.08
|
||||
5606 7 1997-02-01 219959.08
|
||||
5859 2 1997-05-15 210643.96
|
||||
5859 5 1997-05-28 210643.96
|
||||
5859 6 1997-06-15 210643.96
|
||||
5895 1 1997-04-05 201419.83
|
||||
5895 2 1997-04-27 201419.83
|
||||
5895 3 1997-03-15 201419.83
|
||||
5895 4 1997-03-03 201419.83
|
||||
5895 5 1997-04-30 201419.83
|
||||
5895 6 1997-04-19 201419.83
|
||||
DROP DATABASE dbt3_s001;
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
@ -14,129 +14,96 @@ use dbt3_s001;
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate} -> i_l_receiptdate
|
||||
EXPLAIN SELECT *
|
||||
CREATE INDEX i_l_quantity ON lineitem(l_quantity);
|
||||
|
||||
CREATE INDEX i_o_totalprice ON orders(o_totalprice);
|
||||
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
|
||||
set @@use_stat_tables=preferably;
|
||||
|
||||
--disable_result_log
|
||||
--disable_warnings
|
||||
ANALYZE TABLE lineitem, orders;
|
||||
--enable_warnings
|
||||
--enable_result_log
|
||||
|
||||
show create table lineitem;
|
||||
show create table orders;
|
||||
|
||||
set optimizer_use_condition_selectivity=2;
|
||||
|
||||
let $with_filter=
|
||||
set statement optimizer_switch='rowid_filter=on' for;
|
||||
|
||||
let $without_filter=
|
||||
set statement optimizer_switch='rowid_filter=off' for;
|
||||
|
||||
let $q1=
|
||||
SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
|
||||
eval $with_filter EXPLAIN $q1;
|
||||
eval $with_filter EXPLAIN FORMAT=JSON $q1;
|
||||
--sorted_result
|
||||
eval $with_filter $q1;
|
||||
|
||||
eval $without_filter EXPLAIN $q1;
|
||||
eval $without_filter EXPLAIN FORMAT=JSON $q1;
|
||||
--sorted_result
|
||||
eval $without_filter $q1;
|
||||
|
||||
let $q2=
|
||||
SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-02-01' AND
|
||||
l_receiptdate BETWEEN '1997-01-10' AND '1997-01-25';
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate} -> i_l_receiptdate
|
||||
--echo # orders : {i_o_orderdate} -> i_o_orderdate
|
||||
EXPLAIN SELECT *
|
||||
eval $with_filter EXPLAIN $q2;
|
||||
eval $with_filter EXPLAIN FORMAT=JSON $q2;
|
||||
--sorted_result
|
||||
eval $with_filter $q2;
|
||||
|
||||
eval $without_filter EXPLAIN $q2;
|
||||
eval $without_filter EXPLAIN FORMAT=JSON $q2;
|
||||
--sorted_result
|
||||
eval $without_filter $q2;
|
||||
|
||||
let $q3=
|
||||
SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-02-01' AND
|
||||
l_receiptdate BETWEEN '1997-01-10' AND '1997-01-25' AND
|
||||
o_orderdate > '1997-01-15';
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate,
|
||||
--echo # i_l_commitdate} -> i_l_receiptdate
|
||||
EXPLAIN SELECT *
|
||||
eval $with_filter EXPLAIN $q3;
|
||||
eval $with_filter EXPLAIN FORMAT=JSON $q3;
|
||||
--sorted_result
|
||||
eval $with_filter $q3;
|
||||
|
||||
eval $without_filter EXPLAIN $q3;
|
||||
eval $without_filter EXPLAIN FORMAT=JSON $q3;
|
||||
--sorted_result
|
||||
eval $without_filter $q3;
|
||||
|
||||
let $q4=
|
||||
SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-02-01' AND
|
||||
l_receiptdate BETWEEN '1997-01-10' AND '1997-01-25' AND
|
||||
l_commitdate BETWEEN '1997-01-05' AND '1997-01-25';
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate,
|
||||
--echo # i_l_commitdate} -> i_l_commitdate
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-02-01' AND
|
||||
l_receiptdate BETWEEN '1997-01-01' AND '1997-01-25' AND
|
||||
l_commitdate BETWEEN '1997-01-15' AND '1997-01-25';
|
||||
eval $with_filter EXPLAIN $q4;
|
||||
eval $with_filter EXPLAIN FORMAT=JSON $q4;
|
||||
--sorted_result
|
||||
eval $with_filter $q4;
|
||||
|
||||
CREATE INDEX i_l_extendedprice ON lineitem(l_extendedprice);
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate, i_l_commitdate,
|
||||
--echo # i_l_extendedprice} -> i_l_extendedprice
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1996-11-01' AND '1997-01-21' AND
|
||||
l_receiptdate BETWEEN '1996-11-21' AND '1997-01-25' AND
|
||||
l_commitdate BETWEEN '1996-11-25' AND '1997-01-20' AND
|
||||
l_extendedprice BETWEEN 26000 AND 27000;
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_extendedprice} -> i_l_shipdate
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-11' AND '1997-01-21' AND
|
||||
l_extendedprice BETWEEN 26000 AND 27000;
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_extendedprice} -> i_l_extendedprice
|
||||
--echo # intersection point in the I quadrant
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE (l_shipdate BETWEEN '1997-01-11' AND '1997-01-26' OR
|
||||
l_shipdate BETWEEN '1995-02-01' AND '1995-02-14' OR
|
||||
l_shipdate BETWEEN '1994-12-12' AND '1994-12-28'
|
||||
) AND l_extendedprice BETWEEN 26000 AND 27000;
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_extendedprice} -> i_l_shipdate
|
||||
--echo # parallel lines
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE (l_shipdate BETWEEN '1997-01-11' AND '1997-01-26' OR
|
||||
l_shipdate BETWEEN '1995-02-01' AND '1995-02-16' OR
|
||||
l_shipdate BETWEEN '1994-12-12' AND '1994-12-27'
|
||||
) AND l_extendedprice BETWEEN 26000 AND 27000;
|
||||
|
||||
|
||||
CREATE INDEX i_l_discount ON lineitem(l_discount);
|
||||
CREATE INDEX i_l_tax ON lineitem(l_tax);
|
||||
|
||||
--echo # lineitem : {i_l_receiptdate, i_l_shipdate, i_l_commitdate,
|
||||
--echo # i_l_extendedprice, i_l_discount, i_l_tax}
|
||||
--echo # -> {i_l_extendedprice}
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1996-11-01' AND '1997-01-21' AND
|
||||
l_receiptdate BETWEEN '1996-11-21' AND '1997-01-25' AND
|
||||
l_commitdate BETWEEN '1996-11-25' AND '1997-01-20' AND
|
||||
l_extendedprice BETWEEN 26000 AND 27000 AND
|
||||
l_discount BETWEEN 0 AND 0.01 AND
|
||||
l_tax BETWEEN 0.03 AND 0.04;
|
||||
|
||||
DROP INDEX i_l_extendedprice on lineitem;
|
||||
DROP INDEX i_l_discount on lineitem;
|
||||
DROP INDEX i_l_tax on lineitem;
|
||||
|
||||
SET max_rowid_filter_size= 1024;
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_receiptdate, i_l_commitdate}
|
||||
--echo # -> i_l_shipdate
|
||||
--echo # i_l_commitdate isn't in-memory -> isn't used
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1996-12-28' AND '1997-01-20' AND
|
||||
l_receiptdate BETWEEN '1996-12-21' AND '1997-01-25' AND
|
||||
l_commitdate BETWEEN '1996-12-01' AND '1997-01-25';
|
||||
|
||||
SET max_rowid_filter_size= DEFAULT;
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_commitdate} -> i_l_commitdate
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1993-01-01' AND '1997-01-30' AND
|
||||
l_commitdate BETWEEN '1997-01-10' AND '1997-01-12';
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_commitdate} -> i_l_commitdate
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1993-01-01' AND '1997-01-30' AND
|
||||
l_commitdate BETWEEN '1993-01-10' AND '1997-01-12';
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_commitdate, i_l_receiptdate}
|
||||
--echo # -> i_l_receiptdate
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1993-01-01' AND '1997-01-30' AND
|
||||
l_commitdate BETWEEN '1993-01-10' AND '1997-01-12' AND
|
||||
l_receiptdate BETWEEN '1997-01-10' AND '1997-01-12';
|
||||
|
||||
--echo # lineitem : {i_l_shipdate, i_l_receiptdate} -> i_l_receiptdate
|
||||
--echo # indexes with high selectivity
|
||||
EXPLAIN SELECT *
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-09' AND '1997-01-10' AND
|
||||
l_receiptdate BETWEEN '1997-01-09' AND '1997-01-10';
|
||||
eval $without_filter EXPLAIN $q4;
|
||||
eval $without_filter EXPLAIN FORMAT=JSON $q4;
|
||||
--sorted_result
|
||||
eval $without_filter $q4;
|
||||
|
||||
DROP DATABASE dbt3_s001;
|
||||
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
||||
|
||||
|
690
mysql-test/main/rowid_filter_innodb.result
Normal file
690
mysql-test/main/rowid_filter_innodb.result
Normal file
@ -0,0 +1,690 @@
|
||||
SET SESSION STORAGE_ENGINE='InnoDB';
|
||||
DROP DATABASE IF EXISTS dbt3_s001;
|
||||
CREATE DATABASE dbt3_s001;
|
||||
use dbt3_s001;
|
||||
CREATE INDEX i_l_quantity ON lineitem(l_quantity);
|
||||
CREATE INDEX i_o_totalprice ON orders(o_totalprice);
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@use_stat_tables=preferably;
|
||||
ANALYZE TABLE lineitem, orders;
|
||||
show create table lineitem;
|
||||
Table Create Table
|
||||
lineitem CREATE TABLE `lineitem` (
|
||||
`l_orderkey` int(11) NOT NULL DEFAULT 0,
|
||||
`l_partkey` int(11) DEFAULT NULL,
|
||||
`l_suppkey` int(11) DEFAULT NULL,
|
||||
`l_linenumber` int(11) NOT NULL DEFAULT 0,
|
||||
`l_quantity` double DEFAULT NULL,
|
||||
`l_extendedprice` double DEFAULT NULL,
|
||||
`l_discount` double DEFAULT NULL,
|
||||
`l_tax` double DEFAULT NULL,
|
||||
`l_returnflag` char(1) DEFAULT NULL,
|
||||
`l_linestatus` char(1) DEFAULT NULL,
|
||||
`l_shipDATE` date DEFAULT NULL,
|
||||
`l_commitDATE` date DEFAULT NULL,
|
||||
`l_receiptDATE` date DEFAULT NULL,
|
||||
`l_shipinstruct` char(25) DEFAULT NULL,
|
||||
`l_shipmode` char(10) DEFAULT NULL,
|
||||
`l_comment` varchar(44) DEFAULT NULL,
|
||||
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
|
||||
KEY `i_l_shipdate` (`l_shipDATE`),
|
||||
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
|
||||
KEY `i_l_partkey` (`l_partkey`),
|
||||
KEY `i_l_suppkey` (`l_suppkey`),
|
||||
KEY `i_l_receiptdate` (`l_receiptDATE`),
|
||||
KEY `i_l_orderkey` (`l_orderkey`),
|
||||
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
|
||||
KEY `i_l_commitdate` (`l_commitDATE`),
|
||||
KEY `i_l_quantity` (`l_quantity`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show create table orders;
|
||||
Table Create Table
|
||||
orders CREATE TABLE `orders` (
|
||||
`o_orderkey` int(11) NOT NULL,
|
||||
`o_custkey` int(11) DEFAULT NULL,
|
||||
`o_orderstatus` char(1) DEFAULT NULL,
|
||||
`o_totalprice` double DEFAULT NULL,
|
||||
`o_orderDATE` date DEFAULT NULL,
|
||||
`o_orderpriority` char(15) DEFAULT NULL,
|
||||
`o_clerk` char(15) DEFAULT NULL,
|
||||
`o_shippriority` int(11) DEFAULT NULL,
|
||||
`o_comment` varchar(79) DEFAULT NULL,
|
||||
PRIMARY KEY (`o_orderkey`),
|
||||
KEY `i_o_orderdate` (`o_orderDATE`),
|
||||
KEY `i_o_custkey` (`o_custkey`),
|
||||
KEY `i_o_totalprice` (`o_totalprice`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
set optimizer_use_condition_selectivity=2;
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using filter
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["i_l_shipdate", "i_l_quantity"],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_l_quantity",
|
||||
"used_key_parts": ["l_quantity"]
|
||||
},
|
||||
"rows": 605,
|
||||
"selectivity_pct": 10.075
|
||||
},
|
||||
"rows": 510,
|
||||
"filtered": 10.075,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
l_orderkey l_linenumber l_shipdate l_quantity
|
||||
1121 5 1997-04-27 47
|
||||
1121 6 1997-04-21 50
|
||||
1441 7 1997-06-07 50
|
||||
1443 1 1997-02-05 47
|
||||
1473 1 1997-05-05 50
|
||||
1568 2 1997-04-06 46
|
||||
1632 1 1997-01-25 47
|
||||
1632 3 1997-01-29 47
|
||||
1954 7 1997-06-04 49
|
||||
1959 1 1997-05-05 46
|
||||
2151 3 1997-01-20 49
|
||||
2177 5 1997-05-10 46
|
||||
2369 2 1997-01-02 47
|
||||
2469 3 1997-01-11 48
|
||||
2469 6 1997-03-03 49
|
||||
2470 2 1997-06-02 50
|
||||
260 1 1997-03-24 50
|
||||
288 2 1997-04-19 49
|
||||
289 4 1997-03-14 48
|
||||
3009 1 1997-03-19 48
|
||||
3105 3 1997-02-28 48
|
||||
3106 2 1997-02-27 49
|
||||
3429 1 1997-04-08 48
|
||||
3490 2 1997-06-27 50
|
||||
3619 1 1997-01-22 49
|
||||
3619 3 1997-01-31 46
|
||||
3969 3 1997-05-29 46
|
||||
4005 4 1997-01-31 49
|
||||
4036 1 1997-06-21 46
|
||||
4066 4 1997-02-17 49
|
||||
4098 1 1997-01-26 46
|
||||
422 3 1997-06-21 46
|
||||
4258 3 1997-01-02 46
|
||||
4421 2 1997-04-21 46
|
||||
4421 3 1997-05-25 46
|
||||
4453 3 1997-05-29 48
|
||||
4484 7 1997-03-17 50
|
||||
4609 3 1997-02-11 46
|
||||
484 1 1997-03-06 49
|
||||
484 3 1997-01-24 50
|
||||
484 5 1997-03-05 48
|
||||
485 1 1997-03-28 50
|
||||
4868 1 1997-04-29 47
|
||||
4868 3 1997-04-23 49
|
||||
4934 1 1997-05-20 48
|
||||
4967 1 1997-05-27 50
|
||||
5090 2 1997-04-05 46
|
||||
5152 2 1997-03-10 50
|
||||
5158 4 1997-04-10 49
|
||||
5606 3 1997-03-11 46
|
||||
5606 7 1997-02-01 46
|
||||
5762 4 1997-03-02 47
|
||||
581 3 1997-02-27 49
|
||||
5829 5 1997-01-31 49
|
||||
5831 4 1997-02-24 46
|
||||
5895 2 1997-04-27 47
|
||||
5895 3 1997-03-15 49
|
||||
5952 1 1997-06-30 49
|
||||
705 1 1997-04-18 46
|
||||
836 3 1997-03-21 46
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 510 Using index condition; Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["i_l_shipdate", "i_l_quantity"],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 510,
|
||||
"filtered": 10.075,
|
||||
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
|
||||
"attached_condition": "lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45;
|
||||
l_orderkey l_linenumber l_shipdate l_quantity
|
||||
1121 5 1997-04-27 47
|
||||
1121 6 1997-04-21 50
|
||||
1441 7 1997-06-07 50
|
||||
1443 1 1997-02-05 47
|
||||
1473 1 1997-05-05 50
|
||||
1568 2 1997-04-06 46
|
||||
1632 1 1997-01-25 47
|
||||
1632 3 1997-01-29 47
|
||||
1954 7 1997-06-04 49
|
||||
1959 1 1997-05-05 46
|
||||
2151 3 1997-01-20 49
|
||||
2177 5 1997-05-10 46
|
||||
2369 2 1997-01-02 47
|
||||
2469 3 1997-01-11 48
|
||||
2469 6 1997-03-03 49
|
||||
2470 2 1997-06-02 50
|
||||
260 1 1997-03-24 50
|
||||
288 2 1997-04-19 49
|
||||
289 4 1997-03-14 48
|
||||
3009 1 1997-03-19 48
|
||||
3105 3 1997-02-28 48
|
||||
3106 2 1997-02-27 49
|
||||
3429 1 1997-04-08 48
|
||||
3490 2 1997-06-27 50
|
||||
3619 1 1997-01-22 49
|
||||
3619 3 1997-01-31 46
|
||||
3969 3 1997-05-29 46
|
||||
4005 4 1997-01-31 49
|
||||
4036 1 1997-06-21 46
|
||||
4066 4 1997-02-17 49
|
||||
4098 1 1997-01-26 46
|
||||
422 3 1997-06-21 46
|
||||
4258 3 1997-01-02 46
|
||||
4421 2 1997-04-21 46
|
||||
4421 3 1997-05-25 46
|
||||
4453 3 1997-05-29 48
|
||||
4484 7 1997-03-17 50
|
||||
4609 3 1997-02-11 46
|
||||
484 1 1997-03-06 49
|
||||
484 3 1997-01-24 50
|
||||
484 5 1997-03-05 48
|
||||
485 1 1997-03-28 50
|
||||
4868 1 1997-04-29 47
|
||||
4868 3 1997-04-23 49
|
||||
4934 1 1997-05-20 48
|
||||
4967 1 1997-05-27 50
|
||||
5090 2 1997-04-05 46
|
||||
5152 2 1997-03-10 50
|
||||
5158 4 1997-04-10 49
|
||||
5606 3 1997-03-11 46
|
||||
5606 7 1997-02-01 46
|
||||
5762 4 1997-03-02 47
|
||||
581 3 1997-02-27 49
|
||||
5829 5 1997-01-31 49
|
||||
5831 4 1997-02-24 46
|
||||
5895 2 1997-04-27 47
|
||||
5895 3 1997-03-15 49
|
||||
5952 1 1997-06-30 49
|
||||
705 1 1997-04-18 46
|
||||
836 3 1997-03-21 46
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using where; Using index
|
||||
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 98,
|
||||
"filtered": 100,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rows": 1,
|
||||
"filtered": 4.7333,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
484 3 1997-01-24 219920.62
|
||||
5606 6 1997-01-11 219959.08
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 NULL 98 Using where; Using index
|
||||
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "range",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "i_l_shipdate",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_shipDATE"],
|
||||
"rows": 98,
|
||||
"filtered": 100,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "eq_ref",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["o_orderkey"],
|
||||
"ref": ["dbt3_s001.lineitem.l_orderkey"],
|
||||
"rows": 1,
|
||||
"filtered": 4.7333,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
484 3 1997-01-24 219920.62
|
||||
5606 6 1997-01-11 219959.08
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 Using where; Using index
|
||||
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 144,
|
||||
"filtered": 100,
|
||||
"attached_condition": "orders.o_totalprice between 180000 and 230000",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity",
|
||||
"i_l_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rows": 4,
|
||||
"filtered": 0.8557,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate l_quantity o_totalprice
|
||||
1632 1 1997-01-25 47 183286.33
|
||||
1632 3 1997-01-29 47 183286.33
|
||||
2177 5 1997-05-10 46 183493.42
|
||||
2469 3 1997-01-11 48 192074.23
|
||||
2469 6 1997-03-03 49 192074.23
|
||||
3619 1 1997-01-22 49 222274.54
|
||||
3619 3 1997-01-31 46 222274.54
|
||||
484 1 1997-03-06 49 219920.62
|
||||
484 3 1997-01-24 50 219920.62
|
||||
484 5 1997-03-05 48 219920.62
|
||||
4934 1 1997-05-20 48 180478.16
|
||||
5606 3 1997-03-11 46 219959.08
|
||||
5606 7 1997-02-01 46 219959.08
|
||||
5829 5 1997-01-31 49 183734.56
|
||||
5895 2 1997-04-27 47 201419.83
|
||||
5895 3 1997-03-15 49 201419.83
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 Using where; Using index
|
||||
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 144,
|
||||
"filtered": 100,
|
||||
"attached_condition": "orders.o_totalprice between 180000 and 230000",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity",
|
||||
"i_l_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rows": 4,
|
||||
"filtered": 0.8557,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
l_quantity > 45 AND
|
||||
o_totalprice between 180000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate l_quantity o_totalprice
|
||||
1632 1 1997-01-25 47 183286.33
|
||||
1632 3 1997-01-29 47 183286.33
|
||||
2177 5 1997-05-10 46 183493.42
|
||||
2469 3 1997-01-11 48 192074.23
|
||||
2469 6 1997-03-03 49 192074.23
|
||||
3619 1 1997-01-22 49 222274.54
|
||||
3619 3 1997-01-31 46 222274.54
|
||||
484 1 1997-03-06 49 219920.62
|
||||
484 3 1997-01-24 50 219920.62
|
||||
484 5 1997-03-05 48 219920.62
|
||||
4934 1 1997-05-20 48 180478.16
|
||||
5606 3 1997-03-11 46 219959.08
|
||||
5606 7 1997-02-01 46 219959.08
|
||||
5829 5 1997-01-31 49 183734.56
|
||||
5895 2 1997-04-27 47 201419.83
|
||||
5895 3 1997-03-15 49 201419.83
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 Using where; Using index
|
||||
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
|
||||
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 71,
|
||||
"filtered": 100,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rows": 4,
|
||||
"filtered": 8.4929,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
1890 1 1997-04-02 202364.58
|
||||
1890 3 1997-02-09 202364.58
|
||||
1890 4 1997-04-08 202364.58
|
||||
1890 5 1997-04-15 202364.58
|
||||
1890 6 1997-02-13 202364.58
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 4 1997-03-18 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
453 1 1997-06-30 216826.73
|
||||
453 2 1997-06-30 216826.73
|
||||
484 1 1997-03-06 219920.62
|
||||
484 2 1997-04-09 219920.62
|
||||
484 3 1997-01-24 219920.62
|
||||
484 4 1997-04-29 219920.62
|
||||
484 5 1997-03-05 219920.62
|
||||
484 6 1997-04-06 219920.62
|
||||
5606 2 1997-02-23 219959.08
|
||||
5606 3 1997-03-11 219959.08
|
||||
5606 4 1997-02-06 219959.08
|
||||
5606 6 1997-01-11 219959.08
|
||||
5606 7 1997-02-01 219959.08
|
||||
5859 2 1997-05-15 210643.96
|
||||
5859 5 1997-05-28 210643.96
|
||||
5859 6 1997-06-15 210643.96
|
||||
5895 1 1997-04-05 201419.83
|
||||
5895 2 1997-04-27 201419.83
|
||||
5895 3 1997-03-15 201419.83
|
||||
5895 4 1997-03-03 201419.83
|
||||
5895 5 1997-04-30 201419.83
|
||||
5895 6 1997-04-19 201419.83
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 71 Using where; Using index
|
||||
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
|
||||
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "range",
|
||||
"possible_keys": ["PRIMARY", "i_o_totalprice"],
|
||||
"key": "i_o_totalprice",
|
||||
"key_length": "9",
|
||||
"used_key_parts": ["o_totalprice"],
|
||||
"rows": 71,
|
||||
"filtered": 100,
|
||||
"attached_condition": "orders.o_totalprice between 200000 and 230000",
|
||||
"using_index": true
|
||||
},
|
||||
"table": {
|
||||
"table_name": "lineitem",
|
||||
"access_type": "ref",
|
||||
"possible_keys": [
|
||||
"PRIMARY",
|
||||
"i_l_shipdate",
|
||||
"i_l_orderkey",
|
||||
"i_l_orderkey_quantity"
|
||||
],
|
||||
"key": "PRIMARY",
|
||||
"key_length": "4",
|
||||
"used_key_parts": ["l_orderkey"],
|
||||
"ref": ["dbt3_s001.orders.o_orderkey"],
|
||||
"rows": 4,
|
||||
"filtered": 8.4929,
|
||||
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
|
||||
}
|
||||
}
|
||||
}
|
||||
set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
|
||||
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
|
||||
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
|
||||
o_totalprice between 200000 and 230000;
|
||||
o_orderkey l_linenumber l_shipdate o_totalprice
|
||||
1156 3 1997-01-24 217682.81
|
||||
1156 4 1997-01-18 217682.81
|
||||
1156 6 1997-01-27 217682.81
|
||||
1156 7 1997-01-01 217682.81
|
||||
1890 1 1997-04-02 202364.58
|
||||
1890 3 1997-02-09 202364.58
|
||||
1890 4 1997-04-08 202364.58
|
||||
1890 5 1997-04-15 202364.58
|
||||
1890 6 1997-02-13 202364.58
|
||||
2180 2 1997-01-03 208481.57
|
||||
2180 3 1997-01-03 208481.57
|
||||
3619 1 1997-01-22 222274.54
|
||||
3619 3 1997-01-31 222274.54
|
||||
3619 4 1997-03-18 222274.54
|
||||
3619 6 1997-01-25 222274.54
|
||||
453 1 1997-06-30 216826.73
|
||||
453 2 1997-06-30 216826.73
|
||||
484 1 1997-03-06 219920.62
|
||||
484 2 1997-04-09 219920.62
|
||||
484 3 1997-01-24 219920.62
|
||||
484 4 1997-04-29 219920.62
|
||||
484 5 1997-03-05 219920.62
|
||||
484 6 1997-04-06 219920.62
|
||||
5606 2 1997-02-23 219959.08
|
||||
5606 3 1997-03-11 219959.08
|
||||
5606 4 1997-02-06 219959.08
|
||||
5606 6 1997-01-11 219959.08
|
||||
5606 7 1997-02-01 219959.08
|
||||
5859 2 1997-05-15 210643.96
|
||||
5859 5 1997-05-28 210643.96
|
||||
5859 6 1997-06-15 210643.96
|
||||
5895 1 1997-04-05 201419.83
|
||||
5895 2 1997-04-27 201419.83
|
||||
5895 3 1997-03-15 201419.83
|
||||
5895 4 1997-03-03 201419.83
|
||||
5895 5 1997-04-30 201419.83
|
||||
5895 6 1997-04-19 201419.83
|
||||
DROP DATABASE dbt3_s001;
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user