mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MWL#89
Merge MWL#89 with 5.3.
This commit is contained in:
commit
7895c35874
71 changed files with 8692 additions and 1564 deletions
|
@ -33,7 +33,8 @@ connection default;
|
|||
# least it acquires S-locks on some of rows.
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state in ("Sending data","statistics", "preparing") and
|
||||
where state in ("Sending data","statistics", "preparing", "updating",
|
||||
"executing", "Searching rows for update") and
|
||||
info = "$wait_statement";
|
||||
--source include/wait_condition.inc
|
||||
|
||||
|
|
152
mysql-test/include/subselect_mat_cost.inc
Normal file
152
mysql-test/include/subselect_mat_cost.inc
Normal file
|
@ -0,0 +1,152 @@
|
|||
-- echo
|
||||
-- echo /* A. Subqueries in the SELECT clause. */
|
||||
explain
|
||||
select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
|
||||
select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
|
||||
-- echo
|
||||
explain
|
||||
select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
|
||||
select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
|
||||
-- echo
|
||||
explain
|
||||
select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
|
||||
select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
|
||||
|
||||
-- echo
|
||||
-- echo /*
|
||||
-- echo B. "Natural" examples of subqueries without grouping that
|
||||
-- echo cannot be flattened into semijoin.
|
||||
-- echo */
|
||||
|
||||
explain
|
||||
select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
|
||||
select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
|
||||
-- echo
|
||||
explain
|
||||
select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
|
||||
select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
|
||||
-- echo UNION subqueries are currently limited to only use IN-TO-EXISTS.
|
||||
explain
|
||||
select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
|
||||
select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
|
||||
-- echo
|
||||
explain
|
||||
select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
|
||||
select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
|
||||
-- echo
|
||||
explain
|
||||
select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
|
||||
select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
|
||||
|
||||
-- echo
|
||||
-- echo /* C. Subqueries in the WHERE clause with GROUP BY. */
|
||||
explain
|
||||
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
|
||||
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
|
||||
-- echo
|
||||
explain
|
||||
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
|
||||
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
|
||||
-- echo
|
||||
explain
|
||||
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
|
||||
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
|
||||
-- echo
|
||||
explain
|
||||
select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
|
||||
select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
|
||||
-- echo
|
||||
explain
|
||||
select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
|
||||
select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
|
||||
-- echo
|
||||
explain
|
||||
select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
|
||||
select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
|
||||
|
||||
-- echo
|
||||
-- echo /*
|
||||
-- echo D. Subqueries for which materialization is not possible, and the
|
||||
-- echo optimizer reverts to in-to-exists.
|
||||
-- echo */
|
||||
# The first two cases are rejected during the prepare phase by the procedure
|
||||
# subquery_types_allow_materialization().
|
||||
explain
|
||||
select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
|
||||
select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
|
||||
explain
|
||||
select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
|
||||
select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
|
||||
-- echo
|
||||
# The following two subqueries return the result of a string function with a
|
||||
# blob argument, where the return type may be != blob. These are rejected during
|
||||
# cost-based optimization when attempting to create a temporary table.
|
||||
explain
|
||||
select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
|
||||
select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
|
||||
explain
|
||||
select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
|
||||
select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
|
||||
-- echo
|
||||
|
||||
|
||||
-- echo
|
||||
-- echo /* E. Edge cases. */
|
||||
-- echo
|
||||
|
||||
-- echo /* E.1 Both materialization and in_to_exists cannot be off. */
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch = 'materialization=off,in_to_exists=off';
|
||||
--error ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
|
||||
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
|
||||
set @@optimizer_switch = @save_optimizer_switch;
|
||||
|
||||
-- echo /* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
|
||||
explain
|
||||
select '1 - 03' in (select b1 from t2 where b1 > '0');
|
||||
select '1 - 03' in (select b1 from t2 where b1 > '0');
|
||||
|
||||
-- echo /* E.3 Subqueries without tables. */
|
||||
explain
|
||||
select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
|
||||
select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
|
||||
-- echo UNION subqueries are currently limited to only use IN-TO-EXISTS.
|
||||
explain
|
||||
select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
|
||||
select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
|
||||
|
||||
-- echo /* E.4 optimize_cond detects FALSE where/having clause. */
|
||||
explain
|
||||
select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
|
||||
select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
|
||||
|
||||
-- echo /* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
|
||||
-- echo TODO this test produces wrong result due to missing logic to handle the case
|
||||
-- echo when JOIN::optimize detects an empty subquery result.
|
||||
explain
|
||||
select a1 from t1 where a1 in (select max(b1) from t2);
|
||||
select a1 from t1 where a1 in (select max(b1) from t2);
|
||||
-- echo
|
||||
explain
|
||||
select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
|
||||
select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
|
||||
|
||||
-- echo /* E.6 make_join_select detects impossible WHERE. *
|
||||
|
||||
-- echo TODO
|
||||
|
||||
-- echo /* E.7 constant optimization detects "no matching row in const table". */
|
||||
|
||||
-- echo TODO
|
||||
|
||||
-- echo /* E.8 Impossible WHERE noticed after reading const tables. */
|
||||
explain
|
||||
select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
|
||||
select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
|
||||
|
||||
-- echo
|
||||
-- echo /* F. UPDATE/DELETE with subqueries. */
|
||||
-- echo
|
||||
|
||||
-- echo TODO
|
||||
-- echo
|
|
@ -102,6 +102,8 @@ a
|
|||
foo
|
||||
Warnings:
|
||||
Error 1259 ZLIB: Input data corrupted
|
||||
Error 1259 ZLIB: Input data corrupted
|
||||
Error 1259 ZLIB: Input data corrupted
|
||||
explain select *, uncompress(a) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
|
|
|
@ -1742,6 +1742,8 @@ CREATE TABLE empty1 (a int);
|
|||
INSERT INTO t1 VALUES (1,'c'),(2,NULL);
|
||||
INSERT INTO t2 VALUES (3,'m'),(4,NULL);
|
||||
INSERT INTO t3 VALUES (1,'n');
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
#
|
||||
# 1) Test that subquery materialization is setup for query with
|
||||
|
@ -1799,10 +1801,6 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
# 3) Test that subquery materialization is setup for query with
|
||||
# premature optimize() exit due to "Select tables optimized away"
|
||||
#
|
||||
# NOTE: The result of this query is actually wrong; it should be NULL
|
||||
# See BUG#47762. Even so, the test case is still needed to test
|
||||
# that the HAVING subquery does not crash the server
|
||||
#
|
||||
SELECT MIN(pk)
|
||||
FROM t1
|
||||
WHERE pk=NULL
|
||||
|
@ -1869,8 +1867,10 @@ HAVING ('m') IN (
|
|||
SELECT v
|
||||
FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# Cleanup for BUG#46680
|
||||
#
|
||||
|
|
|
@ -1543,8 +1543,7 @@ EXPLAIN SELECT 1 FROM t1 WHERE a IN
|
|||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 144
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1)
|
||||
CREATE TABLE t2 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
|
||||
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
|
||||
|
|
|
@ -1360,12 +1360,158 @@ group by a1,a2,b;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c = t1.c )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b min(c) max(c)
|
||||
a a a a111 d111
|
||||
a a b e112 h112
|
||||
a b a i121 l121
|
||||
a b b m122 p122
|
||||
b a a a211 d211
|
||||
b a b e212 h212
|
||||
b b a i221 l221
|
||||
b b b m222 p222
|
||||
c a a a311 d311
|
||||
c a b e312 h312
|
||||
c b a i321 l321
|
||||
c b b m322 p322
|
||||
d a a a411 d411
|
||||
d a b e412 h412
|
||||
d b a i421 l421
|
||||
d b b m422 p422
|
||||
explain select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b min(c) max(c)
|
||||
a a a a111 d111
|
||||
a a b e112 h112
|
||||
a b a i121 l121
|
||||
a b b m122 p122
|
||||
b a a a211 d211
|
||||
b a b e212 h212
|
||||
b b a i221 l221
|
||||
b b b m222 p222
|
||||
c a a a311 d311
|
||||
c a b e312 h312
|
||||
c b a i321 l321
|
||||
c b b m322 p322
|
||||
d a a a411 d411
|
||||
d a b e412 h412
|
||||
d b a i421 l421
|
||||
d b b m422 p422
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a b h112 e112 h112
|
||||
a b b p122 m122 p122
|
||||
b a b h212 e212 h212
|
||||
b b b p222 m222 p222
|
||||
c a b h312 e312 h312
|
||||
c b b p322 m322 p322
|
||||
d a b h412 e412 h412
|
||||
d b b p422 m422 p422
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a a d111 a111 d111
|
||||
a a b h112 e112 h112
|
||||
a b a l121 i121 l121
|
||||
a b b p122 m122 p122
|
||||
b a a d211 a211 d211
|
||||
b a b h212 e212 h212
|
||||
b b a l221 i221 l221
|
||||
b b b p222 m222 p222
|
||||
c a a d311 a311 d311
|
||||
c a b h312 e312 h312
|
||||
c b a l321 i321 l321
|
||||
c b b p322 m322 p322
|
||||
d a a d411 a411 d411
|
||||
d a b h412 e412 h412
|
||||
d b a l421 i421 l421
|
||||
d b b p422 m422 p422
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a a a111 a111 d111
|
||||
a a b e112 e112 h112
|
||||
a b a i121 i121 l121
|
||||
a b b m122 m122 p122
|
||||
b a a a211 a211 d211
|
||||
b a b e212 e212 h212
|
||||
b b a i221 i221 l221
|
||||
b b b m222 m222 p222
|
||||
c a a a311 a311 d311
|
||||
c a b e312 e312 h312
|
||||
c b a i321 i321 l321
|
||||
c b b m322 m322 p322
|
||||
d a a a411 a411 d411
|
||||
d a b e412 e412 h412
|
||||
d b a i421 i421 l421
|
||||
d b b m422 m422 p422
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a a a111 a111 d111
|
||||
a a b e112 e112 h112
|
||||
a b a i121 i121 l121
|
||||
a b b m122 m122 p122
|
||||
b a a a211 a211 d211
|
||||
b a b e212 e212 h212
|
||||
b b a i221 i221 l221
|
||||
b b b m222 m222 p222
|
||||
c a a a311 a311 d311
|
||||
c a b e312 e312 h312
|
||||
c b a i321 i321 l321
|
||||
c b b m322 m322 o322
|
||||
d a a a411 a411 d411
|
||||
d a b e412 e412 h412
|
||||
d b a i421 i421 l421
|
||||
d b b m422 m422 o422
|
||||
explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
|
@ -2246,17 +2392,17 @@ 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
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 1 Using index
|
||||
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
|
||||
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
|
||||
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 t1_outer index NULL a 10 NULL 15 Using where; Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
|
||||
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
|
||||
|
|
|
@ -1484,7 +1484,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 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 const 1 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);
|
||||
|
|
|
@ -854,7 +854,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
|
||||
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
|
||||
FROM (t3,t4)
|
||||
LEFT JOIN
|
||||
|
@ -966,7 +966,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t8(b);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
|
@ -1015,7 +1015,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t1(b);
|
||||
CREATE INDEX idx_a ON t0(a);
|
||||
EXPLAIN EXTENDED
|
||||
|
@ -1065,7 +1065,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
|
||||
FROM t0,t1
|
||||
|
|
|
@ -239,7 +239,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t8 hash NULL hj_key 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and (`test`.`t8`.`b` = `test`.`t7`.`b`)) and (`test`.`t7`.`b` is not null))) where 1
|
||||
Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t7`.`b` is not null))) where 1
|
||||
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
|
||||
FROM (t6, t7)
|
||||
LEFT JOIN
|
||||
|
@ -560,7 +560,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
|
||||
FROM t0,t1
|
||||
|
@ -656,7 +656,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
SELECT t9.a,t9.b
|
||||
FROM t9;
|
||||
a b
|
||||
|
@ -847,7 +847,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
|
||||
CREATE INDEX idx_b ON t2(b);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
|
||||
|
@ -861,7 +861,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
|
||||
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
|
||||
FROM (t3,t4)
|
||||
LEFT JOIN
|
||||
|
@ -923,7 +923,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t4(b);
|
||||
CREATE INDEX idx_b ON t5(b);
|
||||
EXPLAIN EXTENDED
|
||||
|
@ -973,7 +973,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t8(b);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
|
@ -1022,7 +1022,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t1(b);
|
||||
CREATE INDEX idx_a ON t0(a);
|
||||
EXPLAIN EXTENDED
|
||||
|
@ -1072,7 +1072,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ref idx_b idx_b 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t7`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t7`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
|
||||
FROM t0,t1
|
||||
|
|
|
@ -598,7 +598,7 @@ VALUES
|
|||
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
|
||||
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
|
||||
SELECT 1 as RES FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
|
|
|
@ -347,10 +347,10 @@ WHERE t2.int_key IS NULL
|
|||
GROUP BY t2.pk
|
||||
);
|
||||
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 t2 ref int_key int_key 5 1 100.00 Using index condition; Using where; Using filesort
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using index condition; Using where; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0
|
||||
Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where exists(select `test`.`t2`.`pk` from `test`.`t2` where isnull(`test`.`t2`.`int_key`) group by `test`.`t2`.`pk`)
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
#
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='index_merge_union=on';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch=4;
|
||||
ERROR 42000: Variable 'optimizer_switch' can't be set to the value of '4'
|
||||
set optimizer_switch=NULL;
|
||||
|
@ -43,60 +43,60 @@ set optimizer_switch=default;
|
|||
set optimizer_switch='index_merge=off,index_merge_union=off,default';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch=default;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set @@global.optimizer_switch=default;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
#
|
||||
# Check index_merge's @@optimizer_switch flags
|
||||
#
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
|
||||
BUG#37120 optimizer_switch allowable values not according to specification
|
||||
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,materialization=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,semijoin=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,semijoin=off,materialization=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,materialization=off,semijoin=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,semijoin=off,materialization=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,semijoin=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch='default,materialization=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
|
||||
|
|
|
@ -120,9 +120,9 @@ create table t1 (a int primary key);
|
|||
insert into t1 values (1);
|
||||
explain select * from t1 where 3 in (select (1+1) union select 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
select * from t1 where 3 in (select (1+1) union select 1);
|
||||
a
|
||||
|
|
|
@ -1105,8 +1105,6 @@ count(*)
|
|||
7
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
drop table t1;
|
||||
create table t1 (col1 char(3), col2 integer);
|
||||
insert into t1 (col1) values (cast(1000 as char(3)));
|
||||
|
|
|
@ -423,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
|
||||
|
@ -909,7 +909,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
|
@ -1180,9 +1180,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
INSERT INTO t1 (pseudo) VALUES ('test1');
|
||||
SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
0 IN (SELECT 1 FROM t1 a)
|
||||
|
@ -1190,9 +1190,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL default '0',
|
||||
|
@ -1535,34 +1535,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1624,7 +1624,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`)))
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -2831,10 +2831,9 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
|
|||
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1 1.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`flag` = 'N'))
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
|
||||
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
|
@ -3110,10 +3109,10 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
4
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
@ -3122,8 +3121,8 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
|
@ -3420,7 +3419,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
ALTER TABLE t1 ADD INDEX(a);
|
||||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
a b
|
||||
|
@ -3431,7 +3430,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
|
||||
DROP TABLE t1;
|
||||
create table t1( f1 int,f2 int);
|
||||
insert into t1 values (1,1),(2,2);
|
||||
|
@ -4320,16 +4319,16 @@ CREATE TABLE t1 (a INT);
|
|||
INSERT INTO t1 VALUES (1),(2);
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45061: Incorrectly market field caused wrong result.
|
||||
|
@ -5012,9 +5011,8 @@ explain SELECT * FROM ot1,ot4
|
|||
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
|
||||
FROM it2,it3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 24
|
||||
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it2 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 2 Start temporary
|
||||
1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
|
||||
|
|
|
@ -121,7 +121,7 @@ Handler_read_key 0
|
|||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 29
|
||||
Handler_read_rnd_next 35
|
||||
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
|
||||
Z
|
||||
No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.
|
||||
|
@ -163,7 +163,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and (`test`.`t2`.`a` = `test`.`t1`.`b`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int NOT NULL, b int NOT NULL, key(a));
|
||||
insert into t1 values
|
||||
|
@ -191,7 +191,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and (`test`.`t2`.`a` = `test`.`t1`.`b`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (oref int, grp int);
|
||||
insert into t1 (oref, grp) values
|
||||
|
@ -711,7 +711,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))))
|
||||
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
|
||||
a
|
||||
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
|
||||
|
@ -732,7 +732,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using index condition; Using where; Full scan on NULL key
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
|
||||
SELECT * FROM t1
|
||||
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
|
||||
WHERE t3.name='xxx' AND t2.id=t3.id);
|
||||
|
@ -841,11 +841,16 @@ x ROW(11, 12) = (SELECT MAX(x), 22) ROW(11, 12) IN (SELECT MAX(x), 22)
|
|||
1 0 0
|
||||
2 0 0
|
||||
11 0 0
|
||||
# 2nd and 3rd columns should be same for x == 11 only
|
||||
# 2nd and 3rd columns should be same
|
||||
EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
x ROW(11, 12) = (SELECT MAX(x), 12) ROW(11, 12) IN (SELECT MAX(x), 12)
|
||||
1 0 1
|
||||
2 0 1
|
||||
1 0 0
|
||||
2 0 0
|
||||
11 1 1
|
||||
DROP TABLE t1;
|
||||
# both columns should be same
|
||||
|
@ -971,7 +976,7 @@ i1 i2
|
|||
# Baseline:
|
||||
SHOW STATUS LIKE '%Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 18
|
||||
Handler_read_rnd_next 17
|
||||
|
||||
INSERT INTO t1 VALUES (NULL, NULL);
|
||||
FLUSH STATUS;
|
||||
|
@ -988,7 +993,7 @@ i1 i2
|
|||
# (read record from t1, but do not read from t2)
|
||||
SHOW STATUS LIKE '%Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 19
|
||||
Handler_read_rnd_next 18
|
||||
set @@optimizer_switch=@save_optimizer_switch2;
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.1 tests
|
||||
|
@ -1023,11 +1028,10 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255;
|
|||
explain select t21.* from t21,t22 where t21.a = t22.a and
|
||||
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
|
||||
1 PRIMARY t11 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort; Start temporary
|
||||
1 PRIMARY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
|
||||
2 SUBQUERY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select t21.* from t21,t22 where t21.a = t22.a and
|
||||
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
|
||||
a b c
|
||||
|
@ -1040,9 +1044,8 @@ explain
|
|||
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY subselect3 eq_ref unique_key unique_key 5 func 1
|
||||
3 SUBQUERY Z ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
2 DEPENDENT SUBQUERY Z ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
|
||||
subq
|
||||
NULL
|
||||
|
@ -1112,8 +1115,7 @@ set @@optimizer_switch=@save_optimizer_switch;
|
|||
explain select * from (select a from t0) X where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11
|
||||
1 PRIMARY subselect3 eq_ref unique_key unique_key 5 func 1
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 20
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(<derived2>)
|
||||
2 DERIVED t0 ALL NULL NULL NULL NULL 11
|
||||
drop table t0, t1;
|
||||
create table t0 (a int);
|
||||
|
@ -1125,18 +1127,16 @@ create table t3 (a int);
|
|||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
create table t4 (pk int primary key);
|
||||
insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
and t4.pk=t1.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Using MRR
|
||||
2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3)
|
||||
drop table t1, t3, t4;
|
||||
create table t1 (a int) as select * from t0 where a < 5;
|
||||
set @save_max_heap_table_size=@@max_heap_table_size;
|
||||
|
@ -1167,9 +1167,8 @@ create table t3 ( a int , filler char(100), key(a));
|
|||
insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 1 End temporary
|
||||
select * from t3 where a in (select a from t2);
|
||||
a filler
|
||||
1 filler
|
||||
|
@ -1215,47 +1214,44 @@ create table t3 (a int, b int, filler char(100), key(a));
|
|||
insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C;
|
||||
explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary
|
||||
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
explain select straight_join * from t2 X, t2 Y
|
||||
where X.a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
create table t0 (a int, b int);
|
||||
insert into t0 values(1,1);
|
||||
explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary
|
||||
create table t4 as select a as x, a as y from t1;
|
||||
explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where
|
||||
2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; End temporary
|
||||
drop table t0,t1,t2,t3,t4;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
@ -1264,14 +1260,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
|
|||
create table t2 as select * from t1;
|
||||
explain select * from t2 where a in (select b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
|
||||
1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
|
||||
1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 select a,a from t0;
|
||||
|
@ -1280,16 +1274,14 @@ insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B;
|
|||
set @@optimizer_switch='firstmatch=off';
|
||||
explain select * from t1 where (a,b) in (select a,b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
set @save_optimizer_search_depth=@@optimizer_search_depth;
|
||||
set @@optimizer_search_depth=63;
|
||||
explain select * from t1 where (a,b) in (select a,b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
set @@optimizer_search_depth=@save_optimizer_search_depth;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
drop table t0, t1, t2;
|
||||
|
@ -1299,9 +1291,8 @@ create table t1 as select * from t0;
|
|||
insert into t1 select * from t0;
|
||||
explain select * from t0 where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select * from t0 where a in (select a from t1);
|
||||
a
|
||||
10.24
|
||||
|
@ -1313,9 +1304,8 @@ create table t1 as select * from t0;
|
|||
insert into t1 select * from t0;
|
||||
explain select * from t0 where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select * from t0 where a in (select a from t1);
|
||||
a
|
||||
2008-01-01
|
||||
|
@ -1328,11 +1318,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
|
|||
insert into t2 select * from t2;
|
||||
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 15 func 1
|
||||
2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
|
||||
2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Start temporary
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t2;
|
||||
|
||||
BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307
|
||||
|
@ -1402,10 +1391,9 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
|
|||
WHERE cona.postalStripped='T2H3B2'
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2 1.00
|
||||
1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00
|
||||
1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where
|
||||
1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary
|
||||
Warnings:
|
||||
Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2'))
|
||||
drop table t1,t2,t3;
|
||||
|
|
|
@ -128,7 +128,7 @@ Handler_read_key 0
|
|||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 29
|
||||
Handler_read_rnd_next 35
|
||||
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
|
||||
Z
|
||||
No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.
|
||||
|
@ -170,7 +170,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and (`test`.`t2`.`a` = `test`.`t1`.`b`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int NOT NULL, b int NOT NULL, key(a));
|
||||
insert into t1 values
|
||||
|
@ -198,7 +198,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and (`test`.`t2`.`a` = `test`.`t1`.`b`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (oref int, grp int);
|
||||
insert into t1 (oref, grp) values
|
||||
|
@ -718,7 +718,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))))
|
||||
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
|
||||
a
|
||||
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
|
||||
|
@ -739,7 +739,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using index condition(BKA); Using where; Full scan on NULL key; Using join buffer (flat, BKA join)
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using join buffer (flat, BKA join)
|
||||
SELECT * FROM t1
|
||||
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
|
||||
WHERE t3.name='xxx' AND t2.id=t3.id);
|
||||
|
@ -848,11 +848,16 @@ x ROW(11, 12) = (SELECT MAX(x), 22) ROW(11, 12) IN (SELECT MAX(x), 22)
|
|||
1 0 0
|
||||
2 0 0
|
||||
11 0 0
|
||||
# 2nd and 3rd columns should be same for x == 11 only
|
||||
# 2nd and 3rd columns should be same
|
||||
EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
x ROW(11, 12) = (SELECT MAX(x), 12) ROW(11, 12) IN (SELECT MAX(x), 12)
|
||||
1 0 1
|
||||
2 0 1
|
||||
1 0 0
|
||||
2 0 0
|
||||
11 1 1
|
||||
DROP TABLE t1;
|
||||
# both columns should be same
|
||||
|
@ -978,7 +983,7 @@ i1 i2
|
|||
# Baseline:
|
||||
SHOW STATUS LIKE '%Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 18
|
||||
Handler_read_rnd_next 17
|
||||
|
||||
INSERT INTO t1 VALUES (NULL, NULL);
|
||||
FLUSH STATUS;
|
||||
|
@ -995,7 +1000,7 @@ i1 i2
|
|||
# (read record from t1, but do not read from t2)
|
||||
SHOW STATUS LIKE '%Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 19
|
||||
Handler_read_rnd_next 18
|
||||
set @@optimizer_switch=@save_optimizer_switch2;
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.1 tests
|
||||
|
@ -1030,11 +1035,10 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255;
|
|||
explain select t21.* from t21,t22 where t21.a = t22.a and
|
||||
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
|
||||
1 PRIMARY t21 hash NULL hj_key 4 test.t11.a 26 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t22 hash NULL hj_key 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
|
||||
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
|
||||
2 SUBQUERY t12 hash NULL hj_key 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t11 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort; Start temporary
|
||||
1 PRIMARY t12 hash NULL hj_key 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t21 hash NULL hj_key 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 PRIMARY t22 hash NULL hj_key 4 test.t11.a 26 Using where; End temporary; Using join buffer (incremental, BNLH join)
|
||||
select t21.* from t21,t22 where t21.a = t22.a and
|
||||
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
|
||||
a b c
|
||||
|
@ -1047,9 +1051,8 @@ explain
|
|||
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY subselect3 eq_ref unique_key unique_key 5 func 1
|
||||
3 SUBQUERY Z ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
2 DEPENDENT SUBQUERY Z hash NULL hj_key 5 test.Y.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
|
||||
subq
|
||||
NULL
|
||||
|
@ -1119,8 +1122,7 @@ set @@optimizer_switch=@save_optimizer_switch;
|
|||
explain select * from (select a from t0) X where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11
|
||||
1 PRIMARY subselect3 eq_ref unique_key unique_key 5 func 1
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 20
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(<derived2>); Using join buffer (flat, BNL join)
|
||||
2 DERIVED t0 ALL NULL NULL NULL NULL 11
|
||||
drop table t0, t1;
|
||||
create table t0 (a int);
|
||||
|
@ -1132,18 +1134,16 @@ create table t3 (a int);
|
|||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
create table t4 (pk int primary key);
|
||||
insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
and t4.pk=t1.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Using MRR
|
||||
2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3)
|
||||
drop table t1, t3, t4;
|
||||
create table t1 (a int) as select * from t0 where a < 5;
|
||||
set @save_max_heap_table_size=@@max_heap_table_size;
|
||||
|
@ -1174,9 +1174,8 @@ create table t3 ( a int , filler char(100), key(a));
|
|||
insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 1 Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 1 End temporary; Using join buffer (flat, BKA join)
|
||||
select * from t3 where a in (select a from t2);
|
||||
a filler
|
||||
1 filler
|
||||
|
@ -1222,47 +1221,44 @@ create table t3 (a int, b int, filler char(100), key(a));
|
|||
insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C;
|
||||
explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary; Using join buffer (incremental, BKA join)
|
||||
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
explain select straight_join * from t2 X, t2 Y
|
||||
where X.a in (select straight_join A.a from t1 A, t1 B);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY A ALL NULL NULL NULL NULL 10
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
|
||||
create table t0 (a int, b int);
|
||||
insert into t0 values(1,1);
|
||||
explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary; Using join buffer (flat, BKA join)
|
||||
create table t4 as select a as x, a as y from t1;
|
||||
explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; End temporary; Using join buffer (flat, BKA join)
|
||||
drop table t0,t1,t2,t3,t4;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
@ -1271,14 +1267,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
|
|||
create table t2 as select * from t1;
|
||||
explain select * from t2 where a in (select b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
|
||||
1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
|
||||
1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 select a,a from t0;
|
||||
|
@ -1287,16 +1281,14 @@ insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B;
|
|||
set @@optimizer_switch='firstmatch=off';
|
||||
explain select * from t1 where (a,b) in (select a,b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t2 hash NULL hj_key 10 test.t1.a,test.t1.b 100 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
set @save_optimizer_search_depth=@@optimizer_search_depth;
|
||||
set @@optimizer_search_depth=63;
|
||||
explain select * from t1 where (a,b) in (select a,b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t2 hash NULL hj_key 10 test.t1.a,test.t1.b 100 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
set @@optimizer_search_depth=@save_optimizer_search_depth;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
drop table t0, t1, t2;
|
||||
|
@ -1306,9 +1298,8 @@ create table t1 as select * from t0;
|
|||
insert into t1 select * from t0;
|
||||
explain select * from t0 where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY t1 hash NULL hj_key 3 test.t0.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
select * from t0 where a in (select a from t1);
|
||||
a
|
||||
10.24
|
||||
|
@ -1320,9 +1311,8 @@ create table t1 as select * from t0;
|
|||
insert into t1 select * from t0;
|
||||
explain select * from t0 where a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY t1 hash NULL hj_key 4 test.t0.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
select * from t0 where a in (select a from t1);
|
||||
a
|
||||
2008-01-01
|
||||
|
@ -1335,11 +1325,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
|
|||
insert into t2 select * from t2;
|
||||
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 15 func 1
|
||||
2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
|
||||
2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY X hash NULL hj_key 5 test.t1.a 6 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY Y hash NULL hj_key 5 test.t1.b 6 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 PRIMARY Z hash NULL hj_key 5 test.t1.c 6 Using where; End temporary; Using join buffer (incremental, BNLH join)
|
||||
drop table t0,t1,t2;
|
||||
|
||||
BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307
|
||||
|
@ -1409,10 +1398,9 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
|
|||
WHERE cona.postalStripped='T2H3B2'
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2 1.00
|
||||
1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using join buffer (flat, BKA join)
|
||||
1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where; Using join buffer (flat, BKA join)
|
||||
1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary
|
||||
Warnings:
|
||||
Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2'))
|
||||
drop table t1,t2,t3;
|
||||
|
|
|
@ -15,7 +15,7 @@ ORDER BY count(*);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index; Using temporary
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
# should not crash the next statement
|
||||
SELECT 1 FROM t1
|
||||
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3))
|
||||
|
@ -117,14 +117,14 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x PRIMARY x x x x x x x x
|
||||
x SUBQUERY x x x x x x x x
|
||||
x DEPENDENT SUBQUERY x x x x x x x x
|
||||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
|
||||
a b
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
|
||||
a b
|
||||
1 NULL
|
||||
|
@ -147,28 +147,28 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x PRIMARY x x x x x x x x
|
||||
x SUBQUERY x x x x x x x x
|
||||
x DEPENDENT SUBQUERY x x x x x x x x
|
||||
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
|
||||
a b
|
||||
EXPLAIN
|
||||
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x PRIMARY x x x x x x x x
|
||||
x SUBQUERY x x x x x x x x
|
||||
x DEPENDENT SUBQUERY x x x x x x x x
|
||||
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
|
||||
c d
|
||||
EXPLAIN
|
||||
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x PRIMARY x x x x x x x x
|
||||
x SUBQUERY x x x x x x x x
|
||||
x DEPENDENT SUBQUERY x x x x x x x x
|
||||
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
|
||||
e f
|
||||
EXPLAIN
|
||||
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x PRIMARY x x x x x x x x
|
||||
x SUBQUERY x x x x x x x x
|
||||
x DEPENDENT SUBQUERY x x x x x x x x
|
||||
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
|
||||
c d
|
||||
SELECT * FROM t1 WHERE ( a, b ) NOT IN
|
||||
|
@ -689,3 +689,271 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
2 DEPENDENT SUBQUERY X ALL NULL NULL NULL NULL 10
|
||||
2 DEPENDENT SUBQUERY B ALL a,b NULL NULL NULL 1000 Range checked for each record (index map: 0x3)
|
||||
drop table t1, t2;
|
||||
#
|
||||
# LP BUG#641203 Query returns rows where no result is expected (impossible WHERE)
|
||||
#
|
||||
CREATE TABLE t1 (c1 varchar(1) DEFAULT NULL);
|
||||
CREATE TABLE t2 (c1 varchar(1) DEFAULT NULL);
|
||||
INSERT INTO t2 VALUES ('k'), ('d');
|
||||
CREATE TABLE t3 (c1 varchar(1) DEFAULT NULL);
|
||||
INSERT INTO t3 VALUES ('a'), ('b'), ('c');
|
||||
CREATE TABLE t4 (c1 varchar(1) primary key);
|
||||
INSERT INTO t4 VALUES ('k'), ('d');
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
c1 c1
|
||||
EXPLAIN
|
||||
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
c1 c1
|
||||
EXPLAIN
|
||||
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
c1 c1 c1
|
||||
EXPLAIN
|
||||
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t4 index NULL PRIMARY 3 NULL 2 Using index
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
c1 c1
|
||||
drop table t1, t2, t3, t4;
|
||||
#
|
||||
# LP BUG#675981 Assertion `cache != __null' failed in sub_select_cache()
|
||||
# on EXPLAIN
|
||||
#
|
||||
CREATE TABLE t1 (f1 int,f2 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES ('2','5'),('2',NULL);
|
||||
CREATE TABLE t2 (f1 int, f5 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES (1,0);
|
||||
CREATE TABLE t3 (f4 int) ;
|
||||
INSERT IGNORE INTO t3 VALUES (0),(0);
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off,semijoin=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t2
|
||||
WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#680005 Second assertion `cache != __null' failed in
|
||||
# sub_select_cache() on EXPLAIN
|
||||
#
|
||||
CREATE TABLE t1 (f1 int,f2 int,f4 int,f6 int,KEY (f4)) ;
|
||||
INSERT IGNORE INTO t1 VALUES
|
||||
('1','5','1','0'),('2','1','1','0'),('2','2','2','0'),('0',NULL,'0','0'),
|
||||
('2','1','2','0'),('2','0','0','0'),('2','2','2','0'),('2','8','2','0'),
|
||||
('2','7','2','0'),('2','5','2','0'),('2',NULL,'1','0');
|
||||
CREATE TABLE t2 (f3 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES ('7');
|
||||
CREATE TABLE t3 (f3 int) ;
|
||||
INSERT IGNORE INTO t3 VALUES ('2');
|
||||
EXPLAIN
|
||||
SELECT t1.f4
|
||||
FROM t2 JOIN t1 ON t1.f6
|
||||
WHERE
|
||||
( t1.f2 ) IN (SELECT SUBQUERY2_t1.f3
|
||||
FROM t3 AS SUBQUERY2_t1
|
||||
JOIN
|
||||
(t1 AS SUBQUERY2_t2
|
||||
JOIN
|
||||
t1 AS SUBQUERY2_t3 ON SUBQUERY2_t3.f1)
|
||||
ON SUBQUERY2_t3.f2)
|
||||
GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 PRIMARY t1 index NULL f4 5 NULL 11 Using where
|
||||
2 DEPENDENT SUBQUERY SUBQUERY2_t1 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY SUBQUERY2_t2 index NULL f4 5 NULL 11 Using index
|
||||
2 DEPENDENT SUBQUERY SUBQUERY2_t3 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#680038 bool close_thread_table(THD*, TABLE**):
|
||||
# Assertion `table->key_read == 0' failed in EXPLAIN
|
||||
#
|
||||
CREATE TABLE t1 (f1 int,f3 int,f4 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES (NULL,1,0);
|
||||
CREATE TABLE t2 (f2 int,f4 int,f5 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES (8,0,0),(5,0,0);
|
||||
CREATE TABLE t3 (f4 int,KEY (f4)) ;
|
||||
INSERT IGNORE INTO t3 VALUES (0),(0);
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
(SELECT f2 FROM t2
|
||||
WHERE f4 <= ALL
|
||||
(SELECT SQ1_t1.f4
|
||||
FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
|
||||
GROUP BY SQ1_t1.f4));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary; Using filesort
|
||||
3 SUBQUERY SQ1_t3 index NULL f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# BUG#52317: Assertion failing in Field_varstring::store()
|
||||
# at field.cc:6833
|
||||
#
|
||||
CREATE TABLE t1 (i INTEGER);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE TABLE t2 (i INTEGER, KEY k(i));
|
||||
INSERT INTO t2 VALUES (1), (2);
|
||||
EXPLAIN
|
||||
SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery k k 5 const 2 Using index
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# LP BUG#680846: Crash in clear_tables() with subqueries
|
||||
#
|
||||
CREATE TABLE t1 (f3 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES (0),(0);
|
||||
CREATE TABLE t2 (f1 int,f3 int,f4 varchar(32)) ;
|
||||
INSERT IGNORE INTO t2 VALUES (1,0,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
COUNT(t2.f3) f9
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
COUNT(t2.f3) f9
|
||||
0 2
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
COUNT(t2.f3) f9
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
COUNT(t2.f3) f9
|
||||
0 NULL
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#682683 Crash in create_tmp_table called from
|
||||
# JOIN::init_execution
|
||||
#
|
||||
CREATE TABLE t2 (f1 int) ;
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
CREATE TABLE t1 (f1 int) ;
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
field1
|
||||
NULL
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
field1
|
||||
NULL
|
||||
NULL
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#680943 Assertion `!table || (!table->read_set ||
|
||||
# bitmap_is_set(table->read_set, field_index))' failed with subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 int,f3 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES ('6','0'),('4','0');
|
||||
CREATE TABLE t2 (f1 int,f2 int,f3 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES ('6','0','0'),('2','0','0');
|
||||
SELECT f2
|
||||
FROM (SELECT * FROM t2) AS alias1
|
||||
WHERE (SELECT SQ2_t2.f1
|
||||
FROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3
|
||||
WHERE SQ2_t2.f3 AND alias1.f1)
|
||||
ORDER BY f3 ;
|
||||
f2
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -456,8 +456,8 @@ Handler_read_first 0
|
|||
Handler_read_key 7
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 31
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd_next 42
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
select a from t1 ORDER BY (select d from t2 where b=c);
|
||||
|
@ -482,8 +482,8 @@ Handler_read_first 0
|
|||
Handler_read_key 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 61
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd_next 72
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (distinct ORDER BY)
|
||||
flush status;
|
||||
|
@ -1336,11 +1336,11 @@ Subquery_cache_miss 0
|
|||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 11
|
||||
Handler_read_key 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 145
|
||||
Handler_read_rnd_next 188
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
flush status;
|
||||
select a, b , exists (select * from t2 where b=d) as SUBSE, b in (select d from t2) as SUBSI, (select d from t2 where b=c) SUBSR from t1;
|
||||
|
@ -1364,11 +1364,11 @@ Subquery_cache_miss 18
|
|||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 32
|
||||
Handler_read_key 27
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 84
|
||||
Handler_read_rnd_next 102
|
||||
#several subqueries (several levels)
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
|
@ -3195,7 +3195,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`))))
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch= default;
|
||||
# LP BUG#615760 (part 2: incorrect heap table index flags)
|
||||
|
|
|
@ -30,7 +30,7 @@ create index it3i3 on t3i (c1, c2);
|
|||
insert into t1i select * from t1;
|
||||
insert into t2i select * from t2;
|
||||
insert into t3i select * from t3;
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
/******************************************************************************
|
||||
* Simple tests.
|
||||
******************************************************************************/
|
||||
|
@ -176,33 +176,33 @@ a1 a2
|
|||
1 - 02 2 - 02
|
||||
select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
prepare st1 from
|
||||
"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
execute st1;
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
1 - 02 2 - 02
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
execute st1;
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
1 - 02 2 - 02
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
prepare st1 from
|
||||
"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
execute st1;
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
1 - 02 2 - 02
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
execute st1;
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
1 - 02 2 - 02
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain extended
|
||||
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
|
@ -342,7 +342,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3c`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3c`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
|
||||
select * from t1
|
||||
where (a1, a2) in (select b1, b2 from t2
|
||||
where b2 in (select c2 from t3 t3a where c1 = a1) or
|
||||
|
@ -452,7 +452,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select 1 from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))))
|
||||
Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))))
|
||||
select * from t3
|
||||
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
|
||||
c1 c2
|
||||
|
@ -476,14 +476,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`))))))
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`))))))
|
||||
explain extended
|
||||
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having ((<cache>(`test`.`t1`.`a1`) = '1 - 01') and (<cache>(`test`.`t1`.`a2`) = '2 - 01')))))
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
|
||||
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
|
@ -493,7 +493,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having ((<cache>(`test`.`t1`.`a1`) = '1 - 01') and (<cache>(`test`.`t1`.`a2`) = '2 - 01')))))
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
|
||||
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
|
||||
a1 a2
|
||||
1 - 01 2 - 01
|
||||
|
@ -549,7 +549,7 @@ a1 a2
|
|||
Test that BLOBs are not materialized (except when arguments of some functions).
|
||||
*/
|
||||
# force materialization to be always considered
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
set @prefix_len = 6;
|
||||
set @blob_len = 16;
|
||||
set @suffix_len = @blob_len - @prefix_len;
|
||||
|
@ -583,7 +583,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select 1 from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))))
|
||||
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select `test`.`t2_16`.`b1` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_16
|
||||
where a1 in (select b1 from t2_16 where b1 > '0');
|
||||
|
@ -662,7 +662,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select 1 from `test`.`t1_16` where (<expr_cache><`test`.`t1_16`.`a2`,`test`.`t1_16`.`a1`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `materialized subselect`.`c1`)))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))))
|
||||
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where (<expr_cache><`test`.`t1_16`.`a2`,`test`.`t1_16`.`a1`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `materialized subselect`.`c1`)))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))))
|
||||
drop table t1_16, t2_16, t3_16;
|
||||
set @blob_len = 512;
|
||||
set @suffix_len = @blob_len - @prefix_len;
|
||||
|
@ -696,7 +696,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select 1 from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))))
|
||||
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select `test`.`t2_512`.`b1` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_512
|
||||
where a1 in (select b1 from t2_512 where b1 > '0');
|
||||
|
@ -789,7 +789,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))))
|
||||
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select `test`.`t2_1024`.`b1` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_1024
|
||||
where a1 in (select b1 from t2_1024 where b1 > '0');
|
||||
|
@ -817,7 +817,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in (select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))))
|
||||
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select substr(`test`.`t2_1024`.`b1`,1,1024) from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_1024
|
||||
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
|
||||
|
@ -882,7 +882,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))))
|
||||
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select `test`.`t2_1025`.`b1` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_1025
|
||||
where a1 in (select b1 from t2_1025 where b1 > '0');
|
||||
|
@ -910,7 +910,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in (select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))))
|
||||
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select substr(`test`.`t2_1025`.`b1`,1,1025) from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))))
|
||||
select left(a1,7), left(a2,7)
|
||||
from t1_1025
|
||||
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
|
||||
|
@ -951,7 +951,7 @@ insert into t1bit values (b'010', b'110');
|
|||
insert into t2bit values (b'001', b'101');
|
||||
insert into t2bit values (b'010', b'110');
|
||||
insert into t2bit values (b'110', b'111');
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain extended select bin(a1), bin(a2)
|
||||
from t1bit
|
||||
where (a1, a2) in (select b1, b2 from t2bit);
|
||||
|
@ -994,7 +994,7 @@ drop table t1, t2, t3, t1i, t2i, t3i, columns;
|
|||
/******************************************************************************
|
||||
* Test the cache of the left operand of IN.
|
||||
******************************************************************************/
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
create table t1 (s1 int);
|
||||
create table t2 (s2 int);
|
||||
insert into t1 values (5),(1),(0);
|
||||
|
@ -1097,7 +1097,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
|
||||
select a from t1 group by a
|
||||
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
|
||||
a
|
||||
|
@ -1112,7 +1112,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
|
||||
select a from t1
|
||||
where a in (select c from t2 where d >= some(select e from t3 where b=e));
|
||||
a
|
||||
|
@ -1136,27 +1136,36 @@ drop table t2;
|
|||
create table t1 (a1 int key);
|
||||
create table t2 (b1 int);
|
||||
insert into t1 values (5);
|
||||
Only the last query returns correct result. Filed as BUG#40037.
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
min(a1)
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
min(a1)
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
min(a1)
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
min(a1)
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=off,semijoin=on';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
|
@ -1167,7 +1176,7 @@ drop table t1,t2;
|
|||
create table t1 (a char(2), b varchar(10));
|
||||
insert into t1 values ('a', 'aaa');
|
||||
insert into t1 values ('aa', 'aaaa');
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select a,b from t1 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
|
@ -1187,7 +1196,7 @@ INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
|
|||
CREATE TABLE t2 LIKE t1;
|
||||
INSERT INTO t2 VALUES (1, 1.789);
|
||||
INSERT INTO t2 VALUES (13, 1.454);
|
||||
SET @@optimizer_switch='default,semijoin=on,materialization=on';
|
||||
SET @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
|
||||
|
@ -1208,7 +1217,7 @@ PRIMARY KEY (pk)
|
|||
INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
|
||||
SET @@optimizer_switch='default,semijoin=on,materialization=on';
|
||||
SET @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
|
@ -1237,7 +1246,7 @@ i
|
|||
3
|
||||
4
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set session optimizer_switch='materialization=off';
|
||||
set session optimizer_switch='materialization=off,in_to_exists=on';
|
||||
select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
|
||||
i
|
||||
1
|
||||
|
|
3771
mysql-test/r/subselect_mat_cost.result
Normal file
3771
mysql-test/r/subselect_mat_cost.result
Normal file
File diff suppressed because it is too large
Load diff
234
mysql-test/r/subselect_mat_cost_bugs.result
Normal file
234
mysql-test/r/subselect_mat_cost_bugs.result
Normal file
|
@ -0,0 +1,234 @@
|
|||
#
|
||||
# LP BUG#643424 valgrind warning in choose_subquery_plan()
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2));
|
||||
INSERT INTO t1 VALUES (1,NULL,2);
|
||||
INSERT INTO t1 VALUES (2,7,9);
|
||||
INSERT INTO t1 VALUES (9,NULL,8);
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2));
|
||||
INSERT INTO t2 VALUES (1,1,7);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
SELECT pk FROM t1 WHERE (c2, c1) IN (SELECT c2, c2 FROM t2);
|
||||
pk
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2;
|
||||
#
|
||||
# LP BUG#652727 Crash in create_ref_for_key()
|
||||
#
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk));
|
||||
INSERT INTO t2 VALUES (10,7);
|
||||
INSERT INTO t2 VALUES (11,1);
|
||||
INSERT INTO t2 VALUES (17,NULL);
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk));
|
||||
INSERT INTO t1 VALUES (15,1);
|
||||
INSERT INTO t1 VALUES (19,NULL);
|
||||
CREATE TABLE t3 (c2 int(11) DEFAULT NULL, KEY c2 (c2));
|
||||
INSERT INTO t3 VALUES (1);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
SELECT c2
|
||||
FROM t3
|
||||
WHERE (2, 6) IN (SELECT t1.c1, t1.c1 FROM t1 STRAIGHT_JOIN t2 ON t2.pk = t1.pk);
|
||||
c2
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#641245 Crash in Item_equal::contains
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
c3 varchar(1) DEFAULT NULL,
|
||||
c4 varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2),
|
||||
KEY c3 (c3,c2));
|
||||
INSERT INTO t1 VALUES (10,7,8,'v','v');
|
||||
INSERT INTO t1 VALUES (11,1,9,'r','r');
|
||||
INSERT INTO t1 VALUES (12,5,9,'a','a');
|
||||
create table t1a like t1;
|
||||
insert into t1a select * from t1;
|
||||
create table t1b like t1;
|
||||
insert into t1b select * from t1;
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
c3 varchar(1) DEFAULT NULL,
|
||||
c4 varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2),
|
||||
KEY c3 (c3,c2));
|
||||
INSERT INTO t2 VALUES (1,NULL,2,'w','w');
|
||||
INSERT INTO t2 VALUES (2,7,9,'m','m');
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
EXPLAIN EXTENDED SELECT pk
|
||||
FROM t1
|
||||
WHERE c1 IN
|
||||
(SELECT t1a.c1
|
||||
FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
|
||||
t1a ON (t1a.c2 = t1b.pk AND 2)
|
||||
WHERE t1.pk) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2 index c3 c3 9 NULL 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1a ref c2 c2 5 test.t1b.pk 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <expr_cache><`test`.`t1`.`c1`,`test`.`t1`.`pk`>(<in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t1a`.`c1` from `test`.`t1b` join `test`.`t2` left join `test`.`t1a` on((2 and (`test`.`t1a`.`c2` = `test`.`t1b`.`pk`))) where (`test`.`t1`.`pk` and (`test`.`t1b`.`c4` = `test`.`t2`.`c3`) and (<cache>(`test`.`t1`.`c1`) = `test`.`t1a`.`c1`)))))
|
||||
SELECT pk
|
||||
FROM t1
|
||||
WHERE c1 IN
|
||||
(SELECT t1a.c1
|
||||
FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
|
||||
t1a ON (t1a.c2 = t1b.pk AND 2)
|
||||
WHERE t1.pk) ;
|
||||
pk
|
||||
DROP TABLE t1, t1a, t1b, t2;
|
||||
#
|
||||
# LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'
|
||||
# failed with materialization
|
||||
CREATE TABLE t1 ( pk int(11), PRIMARY KEY (pk)) ;
|
||||
CREATE TABLE t2 ( f2 int(11)) ;
|
||||
CREATE TABLE t3 ( f1 int(11), f3 varchar(1), KEY (f1)) ;
|
||||
INSERT INTO t3 VALUES (7,'f');
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
EXPLAIN
|
||||
SELECT t1.*
|
||||
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
||||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT t1.*
|
||||
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
||||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
|
||||
pk
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#714999 Second crash in select_describe() with nested subqueries
|
||||
#
|
||||
CREATE TABLE t1 ( pk int(11)) ;
|
||||
INSERT INTO t1 VALUES (29);
|
||||
CREATE TABLE t2 ( f1 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES ('f'),('d');
|
||||
CREATE TABLE t3 ( f2 varchar(1)) ;
|
||||
EXPLAIN SELECT f2 FROM t3 WHERE (
|
||||
SELECT MAX( pk ) FROM t1
|
||||
WHERE EXISTS (
|
||||
SELECT DISTINCT f1
|
||||
FROM t2
|
||||
)
|
||||
) IS NULL ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 1
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed
|
||||
#
|
||||
CREATE TABLE t2 ( f2 int(11)) ;
|
||||
CREATE TABLE t1 ( f3 int(11), KEY (f3)) ;
|
||||
INSERT INTO t1 VALUES (6),(4);
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t2) AS a2
|
||||
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
insert into t2 values (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t2) AS a2
|
||||
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
|
||||
#
|
||||
CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
|
||||
INSERT INTO t1 VALUES (28),(29);
|
||||
CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
|
||||
EXPLAIN
|
||||
SELECT alias2.f2 AS field1
|
||||
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
|
||||
WHERE (
|
||||
SELECT t2.f2
|
||||
FROM t2 JOIN t1 ON t1.f1
|
||||
WHERE t1.f1 AND alias2.f10
|
||||
)
|
||||
ORDER BY field1 ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort
|
||||
1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index
|
||||
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
|
||||
3 DEPENDENT SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT alias2.f2 AS field1
|
||||
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
|
||||
WHERE (
|
||||
SELECT t2.f2
|
||||
FROM t2 JOIN t1 ON t1.f1
|
||||
WHERE t1.f1 AND alias2.f10
|
||||
)
|
||||
ORDER BY field1 ;
|
||||
field1
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#718578 Yet another Assertion `!table ||
|
||||
# (!table->read_set || bitmap_is_set(table->read_set, field_index))'
|
||||
CREATE TABLE t1 ( f1 int(11), f2 int(11), f3 int(11)) ;
|
||||
INSERT IGNORE INTO t1 VALUES (28,5,6),(29,NULL,4);
|
||||
CREATE TABLE t2 ( f10 varchar(1) );
|
||||
INSERT IGNORE INTO t2 VALUES (NULL);
|
||||
SELECT f1 AS field1
|
||||
FROM ( SELECT * FROM t1 ) AS alias1
|
||||
WHERE (SELECT t1.f1
|
||||
FROM t2 JOIN t1 ON t1.f2
|
||||
WHERE alias1.f3 AND t1.f3) AND f2
|
||||
ORDER BY field1;
|
||||
field1
|
||||
28
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#601124 Bug in eliminate_item_equal
|
||||
# leads to crash in Item_func::Item_func
|
||||
CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t1 VALUES (5,'m'),(NULL,'c');
|
||||
CREATE TABLE t2 ( f2 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES (6,'f'),(2,'d');
|
||||
CREATE TABLE t3 ( f2 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t3 VALUES (6,'f'),(2,'d');
|
||||
SELECT * FROM t3
|
||||
WHERE ( f2 ) IN (SELECT t1.f1
|
||||
FROM t1 STRAIGHT_JOIN t2 ON t2.f3 = t1.f3
|
||||
WHERE t2.f3 = 'c');
|
||||
f2 f3
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# LP BUG#718593 Crash in substitute_for_best_equal_field ->
|
||||
# eliminate_item_equal -> Item_field::find_item_equal -> Item_equal::contains
|
|
@ -1,6 +1,6 @@
|
|||
select @@optimizer_switch like '%materialization=on%';
|
||||
@@optimizer_switch like '%materialization=on%'
|
||||
1
|
||||
0
|
||||
set optimizer_switch='materialization=off';
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
|
||||
drop view if exists v2;
|
||||
|
@ -427,7 +427,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
|
||||
|
@ -913,7 +913,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
|
@ -1184,9 +1184,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
INSERT INTO t1 (pseudo) VALUES ('test1');
|
||||
SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
0 IN (SELECT 1 FROM t1 a)
|
||||
|
@ -1194,9 +1194,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL default '0',
|
||||
|
@ -1539,34 +1539,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1628,7 +1628,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`)))
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3113,10 +3113,10 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
4
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
@ -3125,8 +3125,8 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
|
@ -3434,7 +3434,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
|
||||
DROP TABLE t1;
|
||||
create table t1( f1 int,f2 int);
|
||||
insert into t1 values (1,1),(2,2);
|
||||
|
@ -4326,13 +4326,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
|
||||
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 noticed after reading const tables
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having 1))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45061: Incorrectly market field caused wrong result.
|
||||
|
@ -5023,4 +5023,4 @@ DROP TABLE IF EXISTS ot1, ot4, it2, it3;
|
|||
set optimizer_switch=default;
|
||||
select @@optimizer_switch like '%materialization=on%';
|
||||
@@optimizer_switch like '%materialization=on%'
|
||||
1
|
||||
0
|
||||
|
|
|
@ -424,7 +424,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
|
||||
|
@ -910,7 +910,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
|
@ -1181,9 +1181,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
INSERT INTO t1 (pseudo) VALUES ('test1');
|
||||
SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
0 IN (SELECT 1 FROM t1 a)
|
||||
|
@ -1191,9 +1191,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL default '0',
|
||||
|
@ -1321,7 +1321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int, b int, index a (a,b));
|
||||
create table t2 (a int, index a (a));
|
||||
|
@ -1364,7 +1364,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
insert into t1 values (3,31);
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
|
@ -1536,34 +1536,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1625,7 +1625,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`)))
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3110,10 +3110,10 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
4
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
@ -3122,8 +3122,8 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
|
@ -3431,7 +3431,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
|
||||
DROP TABLE t1;
|
||||
create table t1( f1 int,f2 int);
|
||||
insert into t1 values (1,1),(2,2);
|
||||
|
@ -4323,13 +4323,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
|
||||
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 noticed after reading const tables
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having 1))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45061: Incorrectly market field caused wrong result.
|
||||
|
|
|
@ -424,7 +424,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
|
||||
|
@ -910,7 +910,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
|
@ -1181,9 +1181,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
INSERT INTO t1 (pseudo) VALUES ('test1');
|
||||
SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
0 IN (SELECT 1 FROM t1 a)
|
||||
|
@ -1191,9 +1191,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL default '0',
|
||||
|
@ -1298,9 +1298,9 @@ a
|
|||
explain extended select * from t2 where t2.a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
2
|
||||
|
@ -1308,9 +1308,9 @@ a
|
|||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
a
|
||||
2
|
||||
|
@ -1318,10 +1318,10 @@ a
|
|||
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 3 100.00 Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int, b int, index a (a,b));
|
||||
create table t2 (a int, index a (a));
|
||||
|
@ -1341,9 +1341,9 @@ a
|
|||
explain extended select * from t2 where t2.a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a))))
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
2
|
||||
|
@ -1351,9 +1351,9 @@ a
|
|||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
a
|
||||
2
|
||||
|
@ -1361,10 +1361,10 @@ a
|
|||
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t3 index a a 5 NULL 3 100.00 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
insert into t1 values (3,31);
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
|
@ -1378,9 +1378,9 @@ a
|
|||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 10005 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
drop table t0, t1, t2, t3;
|
||||
create table t1 (a int, b int);
|
||||
create table t2 (a int, b int);
|
||||
|
@ -1536,34 +1536,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1625,7 +1625,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
|
||||
Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`)))
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -2832,9 +2832,9 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
|
|||
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),(`test`.`t1`.`one`,`test`.`t1`.`two`) in ( <materialize> (select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = 'N') ), <primary_index_lookup>(`test`.`t1`.`one` in <temporary table> on distinct_key where ((`test`.`t1`.`one` = `materialized subselect`.`one`) and (`test`.`t1`.`two` = `materialized subselect`.`two`))))))
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))))
|
||||
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
|
@ -3110,10 +3110,10 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
4
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
@ -3122,8 +3122,8 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
|
@ -3420,7 +3420,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
ALTER TABLE t1 ADD INDEX(a);
|
||||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
a b
|
||||
|
@ -3431,7 +3431,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
|
||||
DROP TABLE t1;
|
||||
create table t1( f1 int,f2 int);
|
||||
insert into t1 values (1,1),(2,2);
|
||||
|
@ -4201,7 +4201,7 @@ CREATE INDEX I2 ON t1 (b);
|
|||
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY t1 index NULL I1 2 NULL 2 Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
|
||||
a b
|
||||
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
|
||||
|
@ -4211,14 +4211,14 @@ CREATE INDEX I2 ON t2 (b);
|
|||
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY t2 index NULL I1 4 NULL 2 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where
|
||||
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
|
||||
a b
|
||||
EXPLAIN
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY t1 index NULL I1 2 NULL 2 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
|
||||
a b
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -4320,16 +4320,16 @@ CREATE TABLE t1 (a INT);
|
|||
INSERT INTO t1 VALUES (1),(2);
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45061: Incorrectly market field caused wrong result.
|
||||
|
@ -5014,7 +5014,7 @@ FROM it2,it3);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it2 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY it2 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -406,24 +406,6 @@ SELECT t1 .varchar_key from t1
|
|||
int_key
|
||||
9
|
||||
7
|
||||
SELECT t0.int_key
|
||||
FROM t0
|
||||
WHERE t0.varchar_nokey IN (
|
||||
SELECT t1_1 .varchar_key
|
||||
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
|
||||
);
|
||||
int_key
|
||||
9
|
||||
7
|
||||
SELECT t0.int_key
|
||||
FROM t0, t2
|
||||
WHERE t0.varchar_nokey IN (
|
||||
SELECT t1_1 .varchar_key
|
||||
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
|
||||
);
|
||||
int_key
|
||||
9
|
||||
7
|
||||
DROP TABLE t0, t1, t2;
|
||||
# End of bug#46550
|
||||
#
|
||||
|
@ -774,11 +756,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
select a from t1
|
||||
where a in (select c from t2 where d >= some(select e from t3 where b=e));
|
||||
a
|
||||
|
@ -811,10 +793,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
|
|||
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
|
||||
1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0))
|
||||
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
|
||||
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
|
||||
pk
|
||||
2
|
||||
|
@ -980,10 +961,9 @@ FROM t1
|
|||
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00
|
||||
2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
|
||||
1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 105.00 Using where; FirstMatch(t2)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_key` < 'n') xor `test`.`t1`.`pk`))
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
|
||||
SELECT varchar_nokey
|
||||
FROM t2
|
||||
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
|
||||
|
@ -1061,11 +1041,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
|
|||
AND t1.val IN (SELECT t3.val FROM t3
|
||||
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
|
||||
1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT *
|
||||
FROM t1
|
||||
WHERE t1.val IN (SELECT t2.val FROM t2
|
||||
|
|
|
@ -32,9 +32,8 @@ a b
|
|||
9 5
|
||||
explain select * from t2 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary
|
||||
select * from t2 where b in (select a from t1);
|
||||
a b
|
||||
1 1
|
||||
|
@ -51,9 +50,8 @@ primary key(pk1, pk2, pk3)
|
|||
insert into t3 select a,a, a,a,a from t0;
|
||||
explain select * from t3 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL b NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary
|
||||
select * from t3 where b in (select a from t1);
|
||||
a b pk1 pk2 pk3
|
||||
1 1 1 1 1
|
||||
|
@ -75,9 +73,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
|
|||
from t0 A, t0 B where B.a <5;
|
||||
explain select * from t3 where b in (select a from t0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref b b 5 test.t0.a 1
|
||||
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary
|
||||
set @save_ecp= @@engine_condition_pushdown;
|
||||
set engine_condition_pushdown=0;
|
||||
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
|
||||
|
@ -101,9 +98,8 @@ set join_buffer_size= @save_join_buffer_size;
|
|||
set max_heap_table_size= @save_max_heap_table_size;
|
||||
explain select * from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t2 index b b 5 NULL 10 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
|
@ -130,9 +126,8 @@ explain select
|
|||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
|
@ -164,8 +159,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
|||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 32
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
|
@ -198,9 +192,8 @@ explain select
|
|||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
|
@ -232,8 +225,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
|||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 52
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
|
@ -349,8 +341,7 @@ WHERE t1.Code IN (
|
|||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
|
||||
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
|
||||
1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1)
|
||||
SELECT Name FROM t1
|
||||
WHERE t1.Code IN (
|
||||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
|
@ -692,9 +683,8 @@ alter table t3 add primary key(id), add key(a);
|
|||
The following must use loose index scan over t3, key a:
|
||||
explain select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using index
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t3 index a a 5 NULL 30000 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
|
||||
select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
count(a)
|
||||
1000
|
||||
|
|
|
@ -39,9 +39,8 @@ a b
|
|||
9 5
|
||||
explain select * from t2 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2 Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary; Using join buffer (flat, BKA join)
|
||||
select * from t2 where b in (select a from t1);
|
||||
a b
|
||||
1 1
|
||||
|
@ -58,9 +57,8 @@ primary key(pk1, pk2, pk3)
|
|||
insert into t3 select a,a, a,a,a from t0;
|
||||
explain select * from t3 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL b NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary; Using join buffer (flat, BKA join)
|
||||
select * from t3 where b in (select a from t1);
|
||||
a b pk1 pk2 pk3
|
||||
1 1 1 1 1
|
||||
|
@ -82,9 +80,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
|
|||
from t0 A, t0 B where B.a <5;
|
||||
explain select * from t3 where b in (select a from t0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref b b 5 test.t0.a 1 Using join buffer (flat, BKA join)
|
||||
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
|
||||
1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary; Using join buffer (flat, BKA join)
|
||||
set @save_ecp= @@engine_condition_pushdown;
|
||||
set engine_condition_pushdown=0;
|
||||
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
|
||||
|
@ -108,9 +105,8 @@ set join_buffer_size= @save_join_buffer_size;
|
|||
set max_heap_table_size= @save_max_heap_table_size;
|
||||
explain select * from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t2 index b b 5 NULL 10 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
|
@ -137,9 +133,8 @@ explain select
|
|||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot hash NULL hj_key 5 test.it.a 32 Using where; Using join buffer (flat, BNLH join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 22 Using where; Start temporary
|
||||
1 PRIMARY ot hash NULL hj_key 5 test.it.a 32 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
|
@ -171,8 +166,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
|||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 32
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
|
@ -196,8 +190,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
|
|||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
3 duplicate 1
|
||||
19 filler1234 1
|
||||
19 duplicate 1
|
||||
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
|
||||
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
|
||||
|
@ -205,9 +199,8 @@ explain select
|
|||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot hash NULL hj_key 5 test.it.a 52 Using where; Using join buffer (flat, BNLH join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 22 Using where; Start temporary
|
||||
1 PRIMARY ot hash NULL hj_key 5 test.it.a 52 Using where; End temporary; Using join buffer (flat, BNLH join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
|
@ -239,8 +232,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
|||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 52
|
||||
1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
|
@ -264,8 +256,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
|
|||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
3 duplicate 1
|
||||
19 filler1234 1
|
||||
19 duplicate 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, key(a));
|
||||
|
@ -356,8 +348,7 @@ WHERE t1.Code IN (
|
|||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
|
||||
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
|
||||
1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1); Using join buffer (flat, BKA join)
|
||||
SELECT Name FROM t1
|
||||
WHERE t1.Code IN (
|
||||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
|
@ -701,9 +692,8 @@ alter table t3 add primary key(id), add key(a);
|
|||
The following must use loose index scan over t3, key a:
|
||||
explain select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using index
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t3 index a a 5 NULL 30000 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
|
||||
select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
count(a)
|
||||
1000
|
||||
|
|
731
mysql-test/r/subselect_sj2_mat.result
Normal file
731
mysql-test/r/subselect_sj2_mat.result
Normal file
|
@ -0,0 +1,731 @@
|
|||
set optimizer_switch='materialization=on';
|
||||
drop table if exists t0, t1, t2, t3;
|
||||
drop view if exists v1;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
a int,
|
||||
b int
|
||||
);
|
||||
insert into t1 values (1,1),(1,1),(2,2);
|
||||
create table t2 (
|
||||
a int,
|
||||
b int,
|
||||
key(b)
|
||||
);
|
||||
insert into t2 select a, a/2 from t0;
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
select * from t2;
|
||||
a b
|
||||
0 0
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
5 3
|
||||
6 3
|
||||
7 4
|
||||
8 4
|
||||
9 5
|
||||
explain select * from t2 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
select * from t2 where b in (select a from t1);
|
||||
a b
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
create table t3 (
|
||||
a int,
|
||||
b int,
|
||||
key(b),
|
||||
pk1 char(200), pk2 char(200), pk3 char(200),
|
||||
primary key(pk1, pk2, pk3)
|
||||
) engine=innodb;
|
||||
insert into t3 select a,a, a,a,a from t0;
|
||||
explain select * from t3 where b in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL b NULL NULL NULL 10
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
select * from t3 where b in (select a from t1);
|
||||
a b pk1 pk2 pk3
|
||||
1 1 1 1 1
|
||||
2 2 2 2 2
|
||||
set @save_max_heap_table_size= @@max_heap_table_size;
|
||||
set max_heap_table_size=16384;
|
||||
set @save_join_buffer_size = @@join_buffer_size;
|
||||
set join_buffer_size= 8000;
|
||||
drop table t3;
|
||||
create table t3 (
|
||||
a int,
|
||||
b int,
|
||||
key(b),
|
||||
pk1 char(200), pk2 char(200),
|
||||
primary key(pk1, pk2)
|
||||
) engine=innodb;
|
||||
insert into t3 select
|
||||
A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
|
||||
from t0 A, t0 B where B.a <5;
|
||||
explain select * from t3 where b in (select a from t0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
|
||||
1 PRIMARY t3 ref b b 5 test.t0.a 1
|
||||
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
|
||||
set @save_ecp= @@engine_condition_pushdown;
|
||||
set engine_condition_pushdown=0;
|
||||
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
|
||||
a b pk1 pk2
|
||||
0 0 0 0
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
3 3 3 3
|
||||
4 4 4 4
|
||||
5 5 5 5
|
||||
6 6 6 6
|
||||
7 7 7 7
|
||||
8 8 8 8
|
||||
9 9 9 9
|
||||
10 10 10 10
|
||||
11 11 11 11
|
||||
12 12 12 12
|
||||
13 13 13 13
|
||||
set engine_condition_pushdown=@save_ecp;
|
||||
set join_buffer_size= @save_join_buffer_size;
|
||||
set max_heap_table_size= @save_max_heap_table_size;
|
||||
explain select * from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t2 index b b 5 NULL 10 Using index
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
select * from t1 where a in (select b from t2);
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
drop table t1, t2, t3;
|
||||
set @save_join_buffer_size = @@join_buffer_size;
|
||||
set join_buffer_size= 8000;
|
||||
create table t1 (a int, filler1 binary(200), filler2 binary(200));
|
||||
insert into t1 select a, 'filler123456', 'filler123456' from t0;
|
||||
insert into t1 select a+10, 'filler123456', 'filler123456' from t0;
|
||||
create table t2 as select * from t1;
|
||||
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
|
||||
insert into t1 values (2, 'duplicate ok', 'duplicate ok');
|
||||
insert into t1 values (18, 'duplicate ok', 'duplicate ok');
|
||||
insert into t2 values (3, 'duplicate ok', 'duplicate ok');
|
||||
insert into t2 values (19, 'duplicate ok', 'duplicate ok');
|
||||
explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
a mid(filler1, 1,10) Z
|
||||
0 filler1234 1
|
||||
1 filler1234 1
|
||||
2 filler1234 1
|
||||
3 filler1234 1
|
||||
4 filler1234 1
|
||||
5 filler1234 1
|
||||
6 filler1234 1
|
||||
7 filler1234 1
|
||||
8 filler1234 1
|
||||
9 filler1234 1
|
||||
10 filler1234 1
|
||||
11 filler1234 1
|
||||
12 filler1234 1
|
||||
13 filler1234 1
|
||||
14 filler1234 1
|
||||
15 filler1234 1
|
||||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
2 duplicate 1
|
||||
18 duplicate 1
|
||||
explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 32
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
a mid(filler1, 1,10) length(filler1)=length(filler2)
|
||||
0 filler1234 1
|
||||
1 filler1234 1
|
||||
2 filler1234 1
|
||||
3 filler1234 1
|
||||
4 filler1234 1
|
||||
5 filler1234 1
|
||||
6 filler1234 1
|
||||
7 filler1234 1
|
||||
8 filler1234 1
|
||||
9 filler1234 1
|
||||
10 filler1234 1
|
||||
11 filler1234 1
|
||||
12 filler1234 1
|
||||
13 filler1234 1
|
||||
14 filler1234 1
|
||||
15 filler1234 1
|
||||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
3 duplicate 1
|
||||
19 duplicate 1
|
||||
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
|
||||
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
|
||||
explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
a mid(filler1, 1,10) Z
|
||||
0 filler1234 1
|
||||
1 filler1234 1
|
||||
2 filler1234 1
|
||||
3 filler1234 1
|
||||
4 filler1234 1
|
||||
5 filler1234 1
|
||||
6 filler1234 1
|
||||
7 filler1234 1
|
||||
8 filler1234 1
|
||||
9 filler1234 1
|
||||
10 filler1234 1
|
||||
11 filler1234 1
|
||||
12 filler1234 1
|
||||
13 filler1234 1
|
||||
14 filler1234 1
|
||||
15 filler1234 1
|
||||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
2 duplicate 1
|
||||
18 duplicate 1
|
||||
explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 22
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY it ALL NULL NULL NULL NULL 52
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2)
|
||||
from t2 ot where a in (select a from t1 it);
|
||||
a mid(filler1, 1,10) length(filler1)=length(filler2)
|
||||
0 filler1234 1
|
||||
1 filler1234 1
|
||||
2 filler1234 1
|
||||
3 filler1234 1
|
||||
4 filler1234 1
|
||||
5 filler1234 1
|
||||
6 filler1234 1
|
||||
7 filler1234 1
|
||||
8 filler1234 1
|
||||
9 filler1234 1
|
||||
10 filler1234 1
|
||||
11 filler1234 1
|
||||
12 filler1234 1
|
||||
13 filler1234 1
|
||||
14 filler1234 1
|
||||
15 filler1234 1
|
||||
16 filler1234 1
|
||||
17 filler1234 1
|
||||
18 filler1234 1
|
||||
19 filler1234 1
|
||||
3 duplicate 1
|
||||
19 duplicate 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, key(a));
|
||||
create table t2 (a int, b int, key(a));
|
||||
create table t3 (a int, b int, key(a));
|
||||
insert into t1 select a,a from t0;
|
||||
insert into t2 select a,a from t0;
|
||||
insert into t3 select a,a from t0;
|
||||
t2 and t3 must be use 'ref', not 'ALL':
|
||||
explain select *
|
||||
from t0 where a in
|
||||
(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Start temporary
|
||||
1 PRIMARY t1 index NULL a 5 NULL 10 Using index; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ref a a 5 test.t1.a 1 Using where; Using index
|
||||
1 PRIMARY t3 ref a a 5 test.t1.a 1 Using where; Using index; End temporary
|
||||
drop table t0, t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
Name char(35) NOT NULL default '',
|
||||
Country char(3) NOT NULL default '',
|
||||
Population int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
INDEX (Population),
|
||||
INDEX (Country)
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
Code char(3) NOT NULL default '',
|
||||
Name char(52) NOT NULL default '',
|
||||
SurfaceArea float(10,2) NOT NULL default '0.00',
|
||||
Population int(11) NOT NULL default '0',
|
||||
Capital int(11) default NULL,
|
||||
PRIMARY KEY (Code),
|
||||
UNIQUE INDEX (Name),
|
||||
INDEX (Population)
|
||||
);
|
||||
CREATE TABLE t3 (
|
||||
Country char(3) NOT NULL default '',
|
||||
Language char(30) NOT NULL default '',
|
||||
Percentage float(3,1) NOT NULL default '0.0',
|
||||
PRIMARY KEY (Country, Language),
|
||||
INDEX (Percentage)
|
||||
);
|
||||
EXPLAIN
|
||||
SELECT Name FROM t2
|
||||
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
|
||||
AND
|
||||
t2.Code IN (SELECT Country FROM t3
|
||||
WHERE Language='English' AND Percentage > 10 AND
|
||||
t2.Population > 100000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Using MRR
|
||||
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where
|
||||
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where
|
||||
DROP TABLE t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
Code char(3) NOT NULL DEFAULT '',
|
||||
Name char(52) NOT NULL DEFAULT '',
|
||||
Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
|
||||
Region char(26) NOT NULL DEFAULT '',
|
||||
SurfaceArea float(10,2) NOT NULL DEFAULT '0.00',
|
||||
IndepYear smallint(6) DEFAULT NULL,
|
||||
Population int(11) NOT NULL DEFAULT '0',
|
||||
LifeExpectancy float(3,1) DEFAULT NULL,
|
||||
GNP float(10,2) DEFAULT NULL,
|
||||
GNPOld float(10,2) DEFAULT NULL,
|
||||
LocalName char(45) NOT NULL DEFAULT '',
|
||||
GovernmentForm char(45) NOT NULL DEFAULT '',
|
||||
HeadOfState char(60) DEFAULT NULL,
|
||||
Capital int(11) DEFAULT NULL,
|
||||
Code2 char(2) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (Code)
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) NOT NULL AUTO_INCREMENT,
|
||||
Name char(35) NOT NULL DEFAULT '',
|
||||
CountryCode char(3) NOT NULL DEFAULT '',
|
||||
District char(20) NOT NULL DEFAULT '',
|
||||
Population int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (ID),
|
||||
KEY CountryCode (CountryCode)
|
||||
);
|
||||
Fill the table with test data
|
||||
This must not use LooseScan:
|
||||
EXPLAIN SELECT Name FROM t1
|
||||
WHERE t1.Code IN (
|
||||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
|
||||
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
|
||||
SELECT Name FROM t1
|
||||
WHERE t1.Code IN (
|
||||
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
|
||||
Name
|
||||
Austria
|
||||
Canada
|
||||
China
|
||||
Czech Republic
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1(a INT);
|
||||
CREATE TABLE t2(c INT);
|
||||
CREATE PROCEDURE p1(v1 int)
|
||||
BEGIN
|
||||
SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2);
|
||||
END
|
||||
//
|
||||
CREATE PROCEDURE p2(v1 int)
|
||||
BEGIN
|
||||
SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2);
|
||||
END
|
||||
//
|
||||
CREATE PROCEDURE p3(v1 int)
|
||||
BEGIN
|
||||
SELECT 1
|
||||
FROM
|
||||
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
|
||||
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
|
||||
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
|
||||
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
|
||||
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
|
||||
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
|
||||
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
|
||||
t1 t57,t1 t58,t1 t59,t1 t60
|
||||
WHERE t01.a IN (SELECT c FROM t2);
|
||||
END
|
||||
//
|
||||
CREATE PROCEDURE p4(v1 int)
|
||||
BEGIN
|
||||
SELECT 1
|
||||
FROM
|
||||
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
|
||||
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
|
||||
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
|
||||
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
|
||||
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
|
||||
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
|
||||
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
|
||||
t1 t57,t1 t58,t1 t59,t1 t60
|
||||
WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2);
|
||||
END
|
||||
//
|
||||
CALL p1(1);
|
||||
1
|
||||
CALL p2(1);
|
||||
1
|
||||
CALL p3(1);
|
||||
1
|
||||
CALL p4(1);
|
||||
1
|
||||
DROP TABLE t1, t2;
|
||||
DROP PROCEDURE p1;
|
||||
DROP PROCEDURE p2;
|
||||
DROP PROCEDURE p3;
|
||||
DROP PROCEDURE p4;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4);
|
||||
create table t1 (a int, b int, key(a));
|
||||
insert into t1 select a,a from t0;
|
||||
create table t2 (a int, b int, primary key(a));
|
||||
insert into t2 select * from t1;
|
||||
Table t2, unlike table t1, should be displayed as pulled out
|
||||
explain extended select * from t0
|
||||
where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
|
||||
t1.b=t2.b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where
|
||||
1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`))
|
||||
update t1 set a=3, b=11 where a=4;
|
||||
update t2 set b=11 where a=3;
|
||||
select * from t0 where t0.a in
|
||||
(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
|
||||
a
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
drop table t0, t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL,
|
||||
PRIMARY KEY (id));
|
||||
CREATE TABLE t2 (
|
||||
id int(11) NOT NULL,
|
||||
fid int(11) NOT NULL,
|
||||
PRIMARY KEY (id));
|
||||
insert into t1 values(1);
|
||||
insert into t2 values(1,7503),(2,1);
|
||||
explain select count(*)
|
||||
from t1
|
||||
where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid );
|
||||
ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery'
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, key (a), key (b));
|
||||
insert into t1 values (2,4),(2,4),(2,4);
|
||||
select t1.a from t1
|
||||
where
|
||||
t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a);
|
||||
a
|
||||
drop table t1;
|
||||
create table t1(a int,b int,key(a),key(b));
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
select 1 from t1
|
||||
where t1.a not in (select 1 from t1
|
||||
where t1.a in (select 1 from t1)
|
||||
group by t1.b);
|
||||
1
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1
|
||||
(EMPNUM CHAR(3) NOT NULL,
|
||||
EMPNAME CHAR(20),
|
||||
GRADE DECIMAL(4),
|
||||
CITY CHAR(15));
|
||||
CREATE TABLE t2
|
||||
(PNUM CHAR(3) NOT NULL,
|
||||
PNAME CHAR(20),
|
||||
PTYPE CHAR(6),
|
||||
BUDGET DECIMAL(9),
|
||||
CITY CHAR(15));
|
||||
CREATE TABLE t3
|
||||
(EMPNUM CHAR(3) NOT NULL,
|
||||
PNUM CHAR(3) NOT NULL,
|
||||
HOURS DECIMAL(5));
|
||||
INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
|
||||
INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
|
||||
INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
|
||||
INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
|
||||
INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
|
||||
INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
|
||||
INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
|
||||
INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
|
||||
INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
|
||||
INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
|
||||
INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
|
||||
INSERT INTO t3 VALUES ('E1','P1',40);
|
||||
INSERT INTO t3 VALUES ('E1','P2',20);
|
||||
INSERT INTO t3 VALUES ('E1','P3',80);
|
||||
INSERT INTO t3 VALUES ('E1','P4',20);
|
||||
INSERT INTO t3 VALUES ('E1','P5',12);
|
||||
INSERT INTO t3 VALUES ('E1','P6',12);
|
||||
INSERT INTO t3 VALUES ('E2','P1',40);
|
||||
INSERT INTO t3 VALUES ('E2','P2',80);
|
||||
INSERT INTO t3 VALUES ('E3','P2',20);
|
||||
INSERT INTO t3 VALUES ('E4','P2',20);
|
||||
INSERT INTO t3 VALUES ('E4','P4',40);
|
||||
INSERT INTO t3 VALUES ('E4','P5',80);
|
||||
SELECT * FROM t1;
|
||||
EMPNUM EMPNAME GRADE CITY
|
||||
E1 Alice 12 Deale
|
||||
E2 Betty 10 Vienna
|
||||
E3 Carmen 13 Vienna
|
||||
E4 Don 12 Deale
|
||||
E5 Ed 13 Akron
|
||||
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
|
||||
SELECT EMPNAME
|
||||
FROM t1
|
||||
WHERE EMPNUM IN
|
||||
(SELECT EMPNUM
|
||||
FROM t3
|
||||
WHERE PNUM IN
|
||||
(SELECT PNUM
|
||||
FROM t2
|
||||
WHERE PTYPE = 'Design'));
|
||||
EMPNAME
|
||||
Alice
|
||||
Betty
|
||||
Don
|
||||
DROP INDEX t1_IDX ON t1;
|
||||
CREATE INDEX t1_IDX ON t1(EMPNUM);
|
||||
SELECT EMPNAME
|
||||
FROM t1
|
||||
WHERE EMPNUM IN
|
||||
(SELECT EMPNUM
|
||||
FROM t3
|
||||
WHERE PNUM IN
|
||||
(SELECT PNUM
|
||||
FROM t2
|
||||
WHERE PTYPE = 'Design'));
|
||||
EMPNAME
|
||||
Alice
|
||||
Betty
|
||||
Don
|
||||
DROP INDEX t1_IDX ON t1;
|
||||
SELECT EMPNAME
|
||||
FROM t1
|
||||
WHERE EMPNUM IN
|
||||
(SELECT EMPNUM
|
||||
FROM t3
|
||||
WHERE PNUM IN
|
||||
(SELECT PNUM
|
||||
FROM t2
|
||||
WHERE PTYPE = 'Design'));
|
||||
EMPNAME
|
||||
Alice
|
||||
Betty
|
||||
Don
|
||||
DROP TABLE t1, t2, t3;
|
||||
CREATE TABLE t1 (f1 INT NOT NULL);
|
||||
CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
a
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1(a int, b int);
|
||||
insert into t1 values (0,0),(1,1),(2,2);
|
||||
create table t2 as select * from t1;
|
||||
create table t3 (pk int, a int, primary key(pk));
|
||||
insert into t3 select a,a from t0;
|
||||
explain
|
||||
select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
|
||||
drop table t0, t1, t2, t3;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb;
|
||||
insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1;
|
||||
insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1;
|
||||
alter table t2 add filler1 int;
|
||||
insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
|
||||
set @save_join_buffer_size=@@join_buffer_size;
|
||||
set join_buffer_size=1;
|
||||
select * from t2 where filler1 in ( select a from t1);
|
||||
a b c filler1
|
||||
set join_buffer_size=default;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int not null);
|
||||
drop procedure if exists p1;
|
||||
CREATE PROCEDURE p1()
|
||||
BEGIN
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION select a from t1;
|
||||
prepare s1 from '
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in (
|
||||
select a from t1 where a in ( select a from t1)
|
||||
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))';
|
||||
execute s1;
|
||||
END;
|
||||
|
|
||||
call p1();
|
||||
a
|
||||
drop procedure p1;
|
||||
drop table t1;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C;
|
||||
create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) NOT NULL DEFAULT '0',
|
||||
`a` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `a` (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
set @a=0;
|
||||
create table t3 as select * from t2 limit 0;
|
||||
insert into t3 select @a:=@a+1, t2.a from t2, t0;
|
||||
insert into t3 select @a:=@a+1, t2.a from t2, t0;
|
||||
insert into t3 select @a:=@a+1, t2.a from t2, t0;
|
||||
alter table t3 add primary key(id), add key(a);
|
||||
The following must use loose index scan over t3, key a:
|
||||
explain select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using index
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
|
||||
2 SUBQUERY t3 index a a 5 NULL 30000 Using index
|
||||
select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
count(a)
|
||||
1000
|
||||
drop table t0,t1,t2,t3;
|
||||
|
||||
BUG#42740: crash in optimize_semijoin_nests
|
||||
|
||||
create table t1 (c6 timestamp,key (c6)) engine=innodb;
|
||||
create table t2 (c2 double) engine=innodb;
|
||||
explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 <null) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
drop table t1, t2;
|
||||
#
|
||||
# BUG#42742: crash in setup_sj_materialization, Copy_field::set
|
||||
#
|
||||
create table t3 ( c1 year) engine=innodb;
|
||||
insert into t3 values (2135),(2142);
|
||||
create table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
|
||||
# The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
|
||||
explain select 1 from t2 where
|
||||
c2 in (select 1 from t3, t2) and
|
||||
c1 in (select convert(c6,char(1)) from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2)
|
||||
drop table t2, t3;
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch like '%materialization=on%';
|
||||
@@optimizer_switch like '%materialization=on%'
|
||||
0
|
|
@ -414,24 +414,6 @@ SELECT t1 .varchar_key from t1
|
|||
int_key
|
||||
9
|
||||
7
|
||||
SELECT t0.int_key
|
||||
FROM t0
|
||||
WHERE t0.varchar_nokey IN (
|
||||
SELECT t1_1 .varchar_key
|
||||
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
|
||||
);
|
||||
int_key
|
||||
9
|
||||
7
|
||||
SELECT t0.int_key
|
||||
FROM t0, t2
|
||||
WHERE t0.varchar_nokey IN (
|
||||
SELECT t1_1 .varchar_key
|
||||
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
|
||||
);
|
||||
int_key
|
||||
9
|
||||
7
|
||||
DROP TABLE t0, t1, t2;
|
||||
# End of bug#46550
|
||||
#
|
||||
|
@ -782,11 +764,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
|
||||
select a from t1
|
||||
where a in (select c from t2 where d >= some(select e from t3 where b=e));
|
||||
a
|
||||
|
@ -819,10 +801,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
|
|||
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
|
||||
1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0))
|
||||
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
|
||||
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
|
||||
pk
|
||||
2
|
||||
|
@ -988,10 +969,9 @@ FROM t1
|
|||
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00
|
||||
2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
|
||||
1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 105.00 Using where; FirstMatch(t2); Using join buffer (flat, BKA join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_key` < 'n') xor `test`.`t1`.`pk`))
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
|
||||
SELECT varchar_nokey
|
||||
FROM t2
|
||||
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
|
||||
|
@ -1069,11 +1049,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
|
|||
AND t1.val IN (SELECT t3.val FROM t3
|
||||
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
|
||||
1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (incremental, BNL join)
|
||||
SELECT *
|
||||
FROM t1
|
||||
WHERE t1.val IN (SELECT t2.val FROM t2
|
||||
|
|
|
@ -1632,11 +1632,11 @@ ORDER BY (SELECT a FROM t2 WHERE b = 12);
|
|||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 UNION t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
NULL UNION <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort
|
||||
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by (select `test`.`t1`.`a` from `test`.`t2` where (`test`.`t2`.`b` = 12))
|
||||
Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #-1
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by (select `a` from `test`.`t2` where (`test`.`t2`.`b` = 12))
|
||||
# Should not crash
|
||||
SELECT * FROM t1 UNION SELECT * FROM t1
|
||||
ORDER BY (SELECT a FROM t2 WHERE b = 12);
|
||||
|
|
|
@ -1364,7 +1364,7 @@ explain select a1,a2,b,min(c),max(c) from t1
|
|||
where exists ( select * from t2 where t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 129 Using index for group-by
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 129 Using where; Using index for group-by
|
||||
2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -2247,17 +2247,17 @@ 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
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 1 Using index
|
||||
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
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
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 t1_outer index NULL a 10 NULL 15 Using where; Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
|
||||
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
|
||||
|
|
|
@ -854,7 +854,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 1 100.00 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
|
||||
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
|
||||
FROM (t3,t4)
|
||||
LEFT JOIN
|
||||
|
@ -966,7 +966,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
|
||||
CREATE INDEX idx_b ON t8(b);
|
||||
EXPLAIN
|
||||
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
|
||||
|
|
|
@ -120,9 +120,9 @@ create table t1 (a int primary key);
|
|||
insert into t1 values (1);
|
||||
explain select * from t1 where 3 in (select (1+1) union select 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using index
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
select * from t1 where 3 in (select (1+1) union select 1);
|
||||
a
|
||||
|
|
|
@ -420,7 +420,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
|
||||
|
@ -908,7 +908,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
|
@ -1179,9 +1179,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
INSERT INTO t1 (pseudo) VALUES ('test1');
|
||||
SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
0 IN (SELECT 1 FROM t1 a)
|
||||
|
@ -1189,9 +1189,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
|
|||
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL default '0',
|
||||
|
@ -1530,34 +1530,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1)))
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1)))
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1619,7 +1619,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 ALL NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where 1
|
||||
Note 1003 select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select `test`.`t1`.`s1` from `test`.`t1` union select `test`.`t1`.`s1` from `test`.`t1`)))
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -2829,10 +2829,9 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
|
|||
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1 1.00
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`flag` = 'N'))
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
|
||||
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
|
@ -3112,10 +3111,10 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
4
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
@ -3124,8 +3123,8 @@ SELECT a FROM t1
|
|||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
a
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
SELECT a FROM t1
|
||||
|
@ -3422,7 +3421,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
ALTER TABLE t1 ADD INDEX(a);
|
||||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
a b
|
||||
|
@ -3433,7 +3432,7 @@ EXPLAIN
|
|||
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
|
||||
DROP TABLE t1;
|
||||
create table t1( f1 int,f2 int);
|
||||
insert into t1 values (1,1),(2,2);
|
||||
|
|
|
@ -2052,7 +2052,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
|
|||
--error 1242
|
||||
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
|
||||
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
@ -2060,7 +2060,7 @@ SELECT a FROM t1 GROUP BY a
|
|||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
@ -2068,7 +2068,7 @@ SELECT a FROM t1 GROUP BY a
|
|||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
|
@ -2076,7 +2076,7 @@ SELECT a FROM t1
|
|||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
|
|
|
@ -17,3 +17,4 @@ main.mysqlhotcopy_archive: bug#54129 2010-06-04 Horst
|
|||
main.events_time_zone : Test is not predictable as it depends on precise timing.
|
||||
main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
|
||||
main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
|
||||
main.subselect_mat_cost : MWL#89 tests that must be adjusted to the cost model introduced after the code review
|
||||
|
|
|
@ -1120,6 +1120,9 @@ INSERT INTO t1 VALUES (1,'c'),(2,NULL);
|
|||
INSERT INTO t2 VALUES (3,'m'),(4,NULL);
|
||||
INSERT INTO t3 VALUES (1,'n');
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
--echo
|
||||
--echo #
|
||||
--echo # 1) Test that subquery materialization is setup for query with
|
||||
|
@ -1167,10 +1170,6 @@ FROM t2);
|
|||
--echo # 3) Test that subquery materialization is setup for query with
|
||||
--echo # premature optimize() exit due to "Select tables optimized away"
|
||||
--echo #
|
||||
--echo # NOTE: The result of this query is actually wrong; it should be NULL
|
||||
--echo # See BUG#47762. Even so, the test case is still needed to test
|
||||
--echo # that the HAVING subquery does not crash the server
|
||||
--echo #
|
||||
SELECT MIN(pk)
|
||||
FROM t1
|
||||
WHERE pk=NULL
|
||||
|
@ -1229,6 +1228,8 @@ HAVING ('m') IN (
|
|||
SELECT v
|
||||
FROM t2);
|
||||
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # Cleanup for BUG#46680
|
||||
--echo #
|
||||
|
|
|
@ -406,11 +406,61 @@ explain select a1,a2,b,min(c),max(c) from t1
|
|||
where exists ( select * from t2 where t2.c = t1.c )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c = t1.c )
|
||||
group by a1,a2,b;
|
||||
|
||||
# the sub-select is unrelated to MIN/MAX
|
||||
explain select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,min(c),max(c) from t1
|
||||
where exists ( select * from t2 where t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
# correlated subselect that doesn't reference the min/max argument
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
# correlated subselect that references the min/max argument
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
|
||||
|
||||
# A,B,C) Predicates referencing mixed classes of attributes
|
||||
# plans
|
||||
|
|
|
@ -2078,7 +2078,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
|
|||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
|
||||
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
@ -2086,7 +2086,7 @@ SELECT a FROM t1 GROUP BY a
|
|||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
|
||||
|
@ -2094,7 +2094,7 @@ SELECT a FROM t1 GROUP BY a
|
|||
SELECT a FROM t1 GROUP BY a
|
||||
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
|
@ -2102,7 +2102,7 @@ SELECT a FROM t1
|
|||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
|
||||
|
||||
--sorted_result
|
||||
SELECT a FROM t1
|
||||
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
|
||||
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
|
||||
|
|
|
@ -683,7 +683,8 @@ SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1;
|
|||
# The x alias is used below to workaround bug #40674.
|
||||
# Regression tests for sum function on outer column in subselect from dual:
|
||||
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1;
|
||||
--echo # 2nd and 3rd columns should be same for x == 11 only
|
||||
--echo # 2nd and 3rd columns should be same
|
||||
EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -619,3 +619,239 @@ select a,
|
|||
from t1 A;
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#641203 Query returns rows where no result is expected (impossible WHERE)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c1 varchar(1) DEFAULT NULL);
|
||||
CREATE TABLE t2 (c1 varchar(1) DEFAULT NULL);
|
||||
INSERT INTO t2 VALUES ('k'), ('d');
|
||||
CREATE TABLE t3 (c1 varchar(1) DEFAULT NULL);
|
||||
INSERT INTO t3 VALUES ('a'), ('b'), ('c');
|
||||
CREATE TABLE t4 (c1 varchar(1) primary key);
|
||||
INSERT INTO t4 VALUES ('k'), ('d');
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
EXPLAIN
|
||||
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
|
||||
drop table t1, t2, t3, t4;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#675981 Assertion `cache != __null' failed in sub_select_cache()
|
||||
--echo # on EXPLAIN
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 int,f2 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES ('2','5'),('2',NULL);
|
||||
|
||||
CREATE TABLE t2 (f1 int, f5 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES (1,0);
|
||||
|
||||
CREATE TABLE t3 (f4 int) ;
|
||||
INSERT IGNORE INTO t3 VALUES (0),(0);
|
||||
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off,semijoin=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t2
|
||||
WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#680005 Second assertion `cache != __null' failed in
|
||||
--echo # sub_select_cache() on EXPLAIN
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 int,f2 int,f4 int,f6 int,KEY (f4)) ;
|
||||
INSERT IGNORE INTO t1 VALUES
|
||||
('1','5','1','0'),('2','1','1','0'),('2','2','2','0'),('0',NULL,'0','0'),
|
||||
('2','1','2','0'),('2','0','0','0'),('2','2','2','0'),('2','8','2','0'),
|
||||
('2','7','2','0'),('2','5','2','0'),('2',NULL,'1','0');
|
||||
|
||||
CREATE TABLE t2 (f3 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES ('7');
|
||||
|
||||
CREATE TABLE t3 (f3 int) ;
|
||||
INSERT IGNORE INTO t3 VALUES ('2');
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.f4
|
||||
FROM t2 JOIN t1 ON t1.f6
|
||||
WHERE
|
||||
( t1.f2 ) IN (SELECT SUBQUERY2_t1.f3
|
||||
FROM t3 AS SUBQUERY2_t1
|
||||
JOIN
|
||||
(t1 AS SUBQUERY2_t2
|
||||
JOIN
|
||||
t1 AS SUBQUERY2_t3 ON SUBQUERY2_t3.f1)
|
||||
ON SUBQUERY2_t3.f2)
|
||||
GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10;
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#680038 bool close_thread_table(THD*, TABLE**):
|
||||
--echo # Assertion `table->key_read == 0' failed in EXPLAIN
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 int,f3 int,f4 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES (NULL,1,0);
|
||||
|
||||
CREATE TABLE t2 (f2 int,f4 int,f5 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES (8,0,0),(5,0,0);
|
||||
|
||||
CREATE TABLE t3 (f4 int,KEY (f4)) ;
|
||||
INSERT IGNORE INTO t3 VALUES (0),(0);
|
||||
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE
|
||||
(SELECT f2 FROM t2
|
||||
WHERE f4 <= ALL
|
||||
(SELECT SQ1_t1.f4
|
||||
FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
|
||||
GROUP BY SQ1_t1.f4));
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#52317: Assertion failing in Field_varstring::store()
|
||||
--echo # at field.cc:6833
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (i INTEGER);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE TABLE t2 (i INTEGER, KEY k(i));
|
||||
INSERT INTO t2 VALUES (1), (2);
|
||||
|
||||
EXPLAIN
|
||||
SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
|
||||
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#680846: Crash in clear_tables() with subqueries
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f3 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES (0),(0);
|
||||
|
||||
CREATE TABLE t2 (f1 int,f3 int,f4 varchar(32)) ;
|
||||
INSERT IGNORE INTO t2 VALUES (1,0,'f');
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
|
||||
# these queries are like the ones above, but without the ON clause,
|
||||
# resulting in a different crash (failed assert)
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
GROUP BY f9;
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
FROM t2 JOIN t1
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#682683 Crash in create_tmp_table called from
|
||||
--echo # JOIN::init_execution
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t2 (f1 int) ;
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t1 (f1 int) ;
|
||||
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
EXPLAIN
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#680943 Assertion `!table || (!table->read_set ||
|
||||
--echo # bitmap_is_set(table->read_set, field_index))' failed with subquery
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 int,f3 int) ;
|
||||
INSERT IGNORE INTO t1 VALUES ('6','0'),('4','0');
|
||||
|
||||
CREATE TABLE t2 (f1 int,f2 int,f3 int) ;
|
||||
INSERT IGNORE INTO t2 VALUES ('6','0','0'),('2','0','0');
|
||||
|
||||
SELECT f2
|
||||
FROM (SELECT * FROM t2) AS alias1
|
||||
WHERE (SELECT SQ2_t2.f1
|
||||
FROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3
|
||||
WHERE SQ2_t2.f3 AND alias1.f1)
|
||||
ORDER BY f3 ;
|
||||
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -48,7 +48,7 @@ insert into t2i select * from t2;
|
|||
insert into t3i select * from t3;
|
||||
|
||||
# force the use of materialization
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
/******************************************************************************
|
||||
* Simple tests.
|
||||
|
@ -111,22 +111,22 @@ select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
|
|||
|
||||
# test re-optimization/re-execution with different execution methods
|
||||
# prepare once, exec with different modes
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
prepare st1 from
|
||||
"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
execute st1;
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
execute st1;
|
||||
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
prepare st1 from
|
||||
"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
execute st1;
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=on';
|
||||
execute st1;
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
# materialize the result of ORDER BY
|
||||
# non-indexed fields
|
||||
|
@ -327,7 +327,7 @@ select * from t1 order by (select col from columns limit 1);
|
|||
Test that BLOBs are not materialized (except when arguments of some functions).
|
||||
*/
|
||||
# force materialization to be always considered
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
set @prefix_len = 6;
|
||||
|
||||
# BLOB == 16 (small blobs that could be stored in HEAP tables)
|
||||
|
@ -680,7 +680,7 @@ insert into t2bit values (b'001', b'101');
|
|||
insert into t2bit values (b'010', b'110');
|
||||
insert into t2bit values (b'110', b'111');
|
||||
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
explain extended select bin(a1), bin(a2)
|
||||
from t1bit
|
||||
|
@ -718,7 +718,7 @@ drop table t1, t2, t3, t1i, t2i, t3i, columns;
|
|||
/******************************************************************************
|
||||
* Test the cache of the left operand of IN.
|
||||
******************************************************************************/
|
||||
set @@optimizer_switch='semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
# Test that default values of Cached_item are not used for comparison
|
||||
create table t1 (s1 int);
|
||||
|
@ -812,23 +812,28 @@ drop table t2;
|
|||
create table t1 (a1 int key);
|
||||
create table t2 (b1 int);
|
||||
insert into t1 values (5);
|
||||
|
||||
-- echo Only the last query returns correct result. Filed as BUG#40037.
|
||||
# Query with group by, executed via materialization
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
# Query with group by, executed via IN=>EXISTS
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
|
||||
|
||||
# Executed with materialization
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
# Executed via IN=>EXISTS
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
# Executed with semi-join. Notice, this time we get a different result (NULL).
|
||||
# This is the only correct result of all four queries. This difference is
|
||||
# This is the only correct result of all five queries. This difference is
|
||||
# filed as BUG#40037.
|
||||
set @@optimizer_switch='default,materialization=off';
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=off,semijoin=on';
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
drop table t1,t2;
|
||||
|
@ -840,7 +845,7 @@ create table t1 (a char(2), b varchar(10));
|
|||
insert into t1 values ('a', 'aaa');
|
||||
insert into t1 values ('aa', 'aaaa');
|
||||
|
||||
set @@optimizer_switch='default,semijoin=off';
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
explain select a,b from t1 where b in (select a from t1);
|
||||
select a,b from t1 where b in (select a from t1);
|
||||
prepare st1 from "select a,b from t1 where b in (select a from t1)";
|
||||
|
@ -861,7 +866,7 @@ CREATE TABLE t2 LIKE t1;
|
|||
INSERT INTO t2 VALUES (1, 1.789);
|
||||
INSERT INTO t2 VALUES (13, 1.454);
|
||||
|
||||
SET @@optimizer_switch='default,semijoin=on,materialization=on';
|
||||
SET @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
|
||||
|
@ -883,7 +888,7 @@ INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
|
|||
CREATE TABLE t2 LIKE t1;
|
||||
INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
|
||||
|
||||
SET @@optimizer_switch='default,semijoin=on,materialization=on';
|
||||
SET @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=on';
|
||||
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
|
||||
SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
|
||||
SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
|
||||
|
@ -900,7 +905,7 @@ create table t3(i int);
|
|||
insert into t3 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set session optimizer_switch='materialization=off';
|
||||
set session optimizer_switch='materialization=off,in_to_exists=on';
|
||||
select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
|
|
204
mysql-test/t/subselect_mat_cost.test
Normal file
204
mysql-test/t/subselect_mat_cost.test
Normal file
|
@ -0,0 +1,204 @@
|
|||
#
|
||||
# Tets of cost-based choice between the materialization and in-to-exists
|
||||
# subquery execution strategies (MWL#89)
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t1_1024, t2_1024;
|
||||
drop procedure if exists make_t1_indexes;
|
||||
drop procedure if exists make_t2_indexes;
|
||||
drop procedure if exists remove_t1_indexes;
|
||||
drop procedure if exists remove_t2_indexes;
|
||||
drop procedure if exists add_materialization_data;
|
||||
drop procedure if exists delete_materialization_data;
|
||||
drop procedure if exists set_all_columns_not_null;
|
||||
drop procedure if exists set_all_columns_nullable;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (a1 char(8), a2 char(8), a3 char(8), a4 int);
|
||||
insert into t1 values ('1 - 00', '2 - 00', '3 - 00', 0);
|
||||
insert into t1 values ('1 - 01', '2 - 01', '3 - 01', 1);
|
||||
|
||||
create table t2 (b1 char(8), b2 char(8), b3 char(8), b4 int);
|
||||
insert into t2 values ('1 - 01', '2 - 01', '3 - 01', 1);
|
||||
insert into t2 values ('1 - 01', '2 - 01', '3 - 02', 2);
|
||||
insert into t2 values ('1 - 02', '2 - 02', '3 - 03', 3);
|
||||
insert into t2 values ('1 - 02', '2 - 02', '3 - 04', 4);
|
||||
insert into t2 values ('1 - 03', '2 - 03', '3 - 05', 5);
|
||||
|
||||
create table t1_1024 (a1 blob(1024), a2 blob(1024));
|
||||
insert into t1_1024 values (concat('1 - 00', repeat('x', 1018)), concat('2 - 00', repeat('x', 1018)));
|
||||
insert into t1_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
|
||||
|
||||
create table t2_1024 (b1 blob(1024), b2 blob(1024));
|
||||
insert into t2_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
|
||||
insert into t2_1024 values (concat('1 - 02', repeat('x', 1018)), concat('2 - 02', repeat('x', 1018)));
|
||||
insert into t2_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
|
||||
insert into t2_1024 values (concat('1 - 04', repeat('x', 1018)), concat('2 - 04', repeat('x', 1018)));
|
||||
|
||||
delimiter |;
|
||||
create procedure make_t1_indexes()
|
||||
begin
|
||||
create index it1i1 on t1 (a1);
|
||||
create index it1i2 on t1 (a2);
|
||||
create index it1i3 on t1 (a1, a2);
|
||||
create index it1_1024i1 on t1_1024 (a1(6));
|
||||
create index it1_1024i2 on t1_1024 (a2(6));
|
||||
create index it1_1024i3 on t1_1024 (a1(6), a2(6));
|
||||
end|
|
||||
|
||||
create procedure make_t2_indexes()
|
||||
begin
|
||||
create index it2i1 on t2 (b1);
|
||||
create index it2i2 on t2 (b2);
|
||||
create index it2i3 on t2 (b1, b2);
|
||||
create unique index it2i4 on t2 (b1, b2, b3);
|
||||
create index it2_1024i1 on t2_1024 (b1(6));
|
||||
create index it2_1024i2 on t2_1024 (b2(6));
|
||||
create index it2_1024i3 on t2_1024 (b1(6), b2(6));
|
||||
end|
|
||||
|
||||
create procedure remove_t1_indexes()
|
||||
begin
|
||||
drop index it1i1 on t1;
|
||||
drop index it1i2 on t1;
|
||||
drop index it1i3 on t1;
|
||||
drop index it1_1024i1 on t1_1024;
|
||||
drop index it1_1024i2 on t1_1024;
|
||||
drop index it1_1024i3 on t1_1024;
|
||||
end|
|
||||
|
||||
create procedure remove_t2_indexes()
|
||||
begin
|
||||
drop index it2i1 on t2;
|
||||
drop index it2i2 on t2;
|
||||
drop index it2i3 on t2;
|
||||
drop index it2i4 on t2;
|
||||
drop index it2_1024i1 on t2_1024;
|
||||
drop index it2_1024i2 on t2_1024;
|
||||
drop index it2_1024i3 on t2_1024;
|
||||
end|
|
||||
|
||||
create procedure add_materialization_data()
|
||||
begin
|
||||
insert into t1 values ('1 - 03', '2 - 03', '3 - 03', 3);
|
||||
insert into t1 values ('1 - 04', '2 - 04', '3 - 04', 4);
|
||||
insert into t1 values ('1 - 05', '2 - 05', '3 - 05', 5);
|
||||
insert into t1 values ('1 - 06', '2 - 06', '3 - 06', 6);
|
||||
insert into t1 values ('1 - 07', '2 - 07', '3 - 07', 7);
|
||||
insert into t1_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
|
||||
end|
|
||||
|
||||
create procedure delete_materialization_data()
|
||||
begin
|
||||
delete from t1 where a1 >= '1 - 03';
|
||||
delete from t1_1024 where a1 >= '1 - 03';
|
||||
end|
|
||||
|
||||
create procedure set_all_columns_not_null()
|
||||
begin
|
||||
alter table t1 modify a1 char(8) not null, modify a2 char(8) not null, modify a3 char(8) not null;
|
||||
alter table t2 modify b1 char(8) not null, modify b2 char(8) not null, modify b3 char(8) not null;
|
||||
end|
|
||||
|
||||
create procedure set_all_columns_nullable()
|
||||
begin
|
||||
alter table t1 modify a1 char(8) null, modify a2 char(8) null, modify a3 char(8) null;
|
||||
alter table t2 modify b1 char(8) null, modify b2 char(8) null, modify b3 char(8) null;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
-- echo
|
||||
|
||||
-- echo /******************************************************************************
|
||||
-- echo 1. Both materialization and in-to-exists are ON, make a cost-based choice.
|
||||
-- echo ******************************************************************************/
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on';
|
||||
-- echo
|
||||
-- echo /* 1.1 In-to-exists is cheaper */
|
||||
call make_t1_indexes();
|
||||
|
||||
-- echo /* 1.1.1 non-indexed table access */
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 1.1.2 indexed table access, nullabale columns. */
|
||||
call make_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 1.1.3 indexed table access, non-nullabale columns. */
|
||||
call set_all_columns_not_null();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
call set_all_columns_nullable();
|
||||
|
||||
-- echo
|
||||
-- echo /* 1.2 Materialization is cheaper */
|
||||
# make materialization cheaper
|
||||
call add_materialization_data();
|
||||
call remove_t1_indexes();
|
||||
|
||||
-- echo /* 1.2.1 non-indexed table access */
|
||||
call remove_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 1.2.2 indexed table access, nullabale columns. */
|
||||
call make_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 1.2.3 indexed table access, non-nullabale columns. */
|
||||
call set_all_columns_not_null();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
call set_all_columns_nullable();
|
||||
|
||||
|
||||
insert into t1 values ('1 - 02', '2 - 02', '3 - 02', 2);
|
||||
|
||||
-- echo /******************************************************************************
|
||||
-- echo 2. Materialization is OFF, in-to-exists is ON, materialization is cheaper.
|
||||
-- echo ******************************************************************************/
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on';
|
||||
|
||||
-- echo /* 2.1 non-indexed table access */
|
||||
call remove_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 2.2 indexed table access, nullabale columns. */
|
||||
call make_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 2.3 indexed table access, non-nullabale columns. */
|
||||
call set_all_columns_not_null();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
call set_all_columns_nullable();
|
||||
|
||||
|
||||
-- echo /******************************************************************************
|
||||
-- echo 3. Materialization is ON, in-to-exists is OFF, in-to-exists is cheaper.
|
||||
-- echo ******************************************************************************/
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off';
|
||||
# make IN-TO-EXISTS cheaper
|
||||
call delete_materialization_data();
|
||||
call make_t1_indexes();
|
||||
|
||||
-- echo /* 3.1 non-indexed table access */
|
||||
call remove_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 3.2 indexed table access, nullabale columns. */
|
||||
call make_t2_indexes();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
|
||||
-- echo /* 3.3 indexed table access, non-nullabale columns. */
|
||||
call set_all_columns_not_null();
|
||||
-- source include/subselect_mat_cost.inc
|
||||
call set_all_columns_nullable();
|
||||
|
||||
|
||||
drop procedure make_t1_indexes;
|
||||
drop procedure make_t2_indexes;
|
||||
drop procedure remove_t1_indexes;
|
||||
drop procedure remove_t2_indexes;
|
||||
drop procedure add_materialization_data;
|
||||
drop procedure delete_materialization_data;
|
||||
drop procedure set_all_columns_not_null;
|
||||
drop procedure set_all_columns_nullable;
|
||||
drop table t1, t2, t1_1024, t2_1024;
|
311
mysql-test/t/subselect_mat_cost_bugs.test
Normal file
311
mysql-test/t/subselect_mat_cost_bugs.test
Normal file
|
@ -0,0 +1,311 @@
|
|||
#
|
||||
# Test cases for bugs related to the implementation of
|
||||
# MWL#89 cost-based choice between the materialization and in-to-exists
|
||||
#
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#643424 valgrind warning in choose_subquery_plan()
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2));
|
||||
|
||||
INSERT INTO t1 VALUES (1,NULL,2);
|
||||
INSERT INTO t1 VALUES (2,7,9);
|
||||
INSERT INTO t1 VALUES (9,NULL,8);
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2));
|
||||
|
||||
INSERT INTO t2 VALUES (1,1,7);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
|
||||
SELECT pk FROM t1 WHERE (c2, c1) IN (SELECT c2, c2 FROM t2);
|
||||
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#652727 Crash in create_ref_for_key()
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk));
|
||||
|
||||
INSERT INTO t2 VALUES (10,7);
|
||||
INSERT INTO t2 VALUES (11,1);
|
||||
INSERT INTO t2 VALUES (17,NULL);
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (pk));
|
||||
|
||||
INSERT INTO t1 VALUES (15,1);
|
||||
INSERT INTO t1 VALUES (19,NULL);
|
||||
|
||||
CREATE TABLE t3 (c2 int(11) DEFAULT NULL, KEY c2 (c2));
|
||||
INSERT INTO t3 VALUES (1);
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
|
||||
SELECT c2
|
||||
FROM t3
|
||||
WHERE (2, 6) IN (SELECT t1.c1, t1.c1 FROM t1 STRAIGHT_JOIN t2 ON t2.pk = t1.pk);
|
||||
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2, t3;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#641245 Crash in Item_equal::contains
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
c3 varchar(1) DEFAULT NULL,
|
||||
c4 varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2),
|
||||
KEY c3 (c3,c2));
|
||||
|
||||
INSERT INTO t1 VALUES (10,7,8,'v','v');
|
||||
INSERT INTO t1 VALUES (11,1,9,'r','r');
|
||||
INSERT INTO t1 VALUES (12,5,9,'a','a');
|
||||
|
||||
create table t1a like t1;
|
||||
insert into t1a select * from t1;
|
||||
|
||||
create table t1b like t1;
|
||||
insert into t1b select * from t1;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
c1 int(11) DEFAULT NULL,
|
||||
c2 int(11) DEFAULT NULL,
|
||||
c3 varchar(1) DEFAULT NULL,
|
||||
c4 varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY c2 (c2),
|
||||
KEY c3 (c3,c2));
|
||||
|
||||
INSERT INTO t2 VALUES (1,NULL,2,'w','w');
|
||||
INSERT INTO t2 VALUES (2,7,9,'m','m');
|
||||
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
|
||||
let $query=
|
||||
SELECT pk
|
||||
FROM t1
|
||||
WHERE c1 IN
|
||||
(SELECT t1a.c1
|
||||
FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
|
||||
t1a ON (t1a.c2 = t1b.pk AND 2)
|
||||
WHERE t1.pk) ;
|
||||
eval EXPLAIN EXTENDED $query;
|
||||
eval $query;
|
||||
|
||||
DROP TABLE t1, t1a, t1b, t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'
|
||||
--echo # failed with materialization
|
||||
|
||||
CREATE TABLE t1 ( pk int(11), PRIMARY KEY (pk)) ;
|
||||
CREATE TABLE t2 ( f2 int(11)) ;
|
||||
CREATE TABLE t3 ( f1 int(11), f3 varchar(1), KEY (f1)) ;
|
||||
INSERT INTO t3 VALUES (7,'f');
|
||||
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.*
|
||||
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
||||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
|
||||
|
||||
SELECT t1.*
|
||||
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
||||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
|
||||
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#714999 Second crash in select_describe() with nested subqueries
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( pk int(11)) ;
|
||||
INSERT INTO t1 VALUES (29);
|
||||
|
||||
CREATE TABLE t2 ( f1 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES ('f'),('d');
|
||||
|
||||
CREATE TABLE t3 ( f2 varchar(1)) ;
|
||||
|
||||
EXPLAIN SELECT f2 FROM t3 WHERE (
|
||||
SELECT MAX( pk ) FROM t1
|
||||
WHERE EXISTS (
|
||||
SELECT DISTINCT f1
|
||||
FROM t2
|
||||
)
|
||||
) IS NULL ;
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t2 ( f2 int(11)) ;
|
||||
|
||||
CREATE TABLE t1 ( f3 int(11), KEY (f3)) ;
|
||||
INSERT INTO t1 VALUES (6),(4);
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t2) AS a2
|
||||
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
|
||||
|
||||
insert into t2 values (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM t2) AS a2
|
||||
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
|
||||
INSERT INTO t1 VALUES (28),(29);
|
||||
|
||||
CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
|
||||
|
||||
EXPLAIN
|
||||
SELECT alias2.f2 AS field1
|
||||
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
|
||||
WHERE (
|
||||
SELECT t2.f2
|
||||
FROM t2 JOIN t1 ON t1.f1
|
||||
WHERE t1.f1 AND alias2.f10
|
||||
)
|
||||
ORDER BY field1 ;
|
||||
|
||||
SELECT alias2.f2 AS field1
|
||||
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
|
||||
WHERE (
|
||||
SELECT t2.f2
|
||||
FROM t2 JOIN t1 ON t1.f1
|
||||
WHERE t1.f1 AND alias2.f10
|
||||
)
|
||||
ORDER BY field1 ;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#718578 Yet another Assertion `!table ||
|
||||
--echo # (!table->read_set || bitmap_is_set(table->read_set, field_index))'
|
||||
|
||||
CREATE TABLE t1 ( f1 int(11), f2 int(11), f3 int(11)) ;
|
||||
INSERT IGNORE INTO t1 VALUES (28,5,6),(29,NULL,4);
|
||||
|
||||
CREATE TABLE t2 ( f10 varchar(1) );
|
||||
INSERT IGNORE INTO t2 VALUES (NULL);
|
||||
|
||||
SELECT f1 AS field1
|
||||
FROM ( SELECT * FROM t1 ) AS alias1
|
||||
WHERE (SELECT t1.f1
|
||||
FROM t2 JOIN t1 ON t1.f2
|
||||
WHERE alias1.f3 AND t1.f3) AND f2
|
||||
ORDER BY field1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#601124 Bug in eliminate_item_equal
|
||||
--echo # leads to crash in Item_func::Item_func
|
||||
|
||||
CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t1 VALUES (5,'m'),(NULL,'c');
|
||||
|
||||
CREATE TABLE t2 ( f2 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t2 VALUES (6,'f'),(2,'d');
|
||||
|
||||
CREATE TABLE t3 ( f2 int(11), f3 varchar(1)) ;
|
||||
INSERT INTO t3 VALUES (6,'f'),(2,'d');
|
||||
|
||||
SELECT * FROM t3
|
||||
WHERE ( f2 ) IN (SELECT t1.f1
|
||||
FROM t1 STRAIGHT_JOIN t2 ON t2.f3 = t1.f3
|
||||
WHERE t2.f3 = 'c');
|
||||
drop table t1,t2,t3;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#718593 Crash in substitute_for_best_equal_field ->
|
||||
--echo # eliminate_item_equal -> Item_field::find_item_equal -> Item_equal::contains
|
||||
|
||||
--disable_parsing # not yet fixed
|
||||
|
||||
CREATE TABLE t1 ( f3 int(11), f10 varchar(1), f11 varchar(1)) ;
|
||||
INSERT IGNORE INTO t1 VALUES (6,'f','f'),(2,'d','d');
|
||||
|
||||
CREATE TABLE t2 ( f12 int(11), f13 int(11)) ;
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t2
|
||||
WHERE (f12) IN (
|
||||
SELECT alias2.f3
|
||||
FROM t1 AS alias1, t1 AS alias2
|
||||
WHERE (alias2.f10 = alias1.f11) AND
|
||||
(alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
|
||||
|
||||
SELECT * FROM t2
|
||||
WHERE (f12) IN (
|
||||
SELECT alias2.f3
|
||||
FROM t1 AS alias1, t1 AS alias2
|
||||
WHERE (alias2.f10 = alias1.f11) AND
|
||||
(alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
|
||||
|
||||
insert into t2 values (1,2), (3,4);
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t2
|
||||
WHERE (f12) IN (
|
||||
SELECT alias2.f3
|
||||
FROM t1 AS alias1, t1 AS alias2
|
||||
WHERE (alias2.f10 = alias1.f11) AND
|
||||
(alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
|
||||
|
||||
SELECT * FROM t2
|
||||
WHERE (f12) IN (
|
||||
SELECT alias2.f3
|
||||
FROM t1 AS alias1, t1 AS alias2
|
||||
WHERE (alias2.f10 = alias1.f11) AND
|
||||
(alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
|
||||
|
||||
set session optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
--enable_parsing
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# Run subselect.test without semi-join optimization (test materialize)
|
||||
#
|
||||
# Run subselect.test without semi-join and materialization optimizations
|
||||
# (test in-to-exists)
|
||||
set optimizer_switch='materialization=off,semijoin=off';
|
||||
|
||||
--source t/subselect.test
|
||||
|
|
|
@ -311,7 +311,7 @@ FROM t0
|
|||
WHERE varchar_nokey IN (
|
||||
SELECT t1 .varchar_key from t1
|
||||
);
|
||||
|
||||
--disable_parsing # wrong duplicate results - LP BUG#702374
|
||||
SELECT t0.int_key
|
||||
FROM t0
|
||||
WHERE t0.varchar_nokey IN (
|
||||
|
@ -325,7 +325,7 @@ WHERE t0.varchar_nokey IN (
|
|||
SELECT t1_1 .varchar_key
|
||||
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
|
||||
);
|
||||
|
||||
--enable_parsing
|
||||
DROP TABLE t0, t1, t2;
|
||||
|
||||
--echo # End of bug#46550
|
||||
|
|
9
mysql-test/t/subselect_sj2_mat.test
Normal file
9
mysql-test/t/subselect_sj2_mat.test
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# Run subselect_sj2.test with subquery materialization.
|
||||
#
|
||||
set optimizer_switch='materialization=on';
|
||||
|
||||
--source t/subselect_sj2.test
|
||||
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch like '%materialization=on%';
|
|
@ -612,10 +612,34 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
|||
}
|
||||
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
|
||||
}
|
||||
|
||||
bool write_record= false;
|
||||
if (error == 0)
|
||||
{
|
||||
param->examined_rows++;
|
||||
|
||||
if (error == 0 && (!select || select->skip_record(thd) > 0))
|
||||
if (select && select->cond)
|
||||
{
|
||||
/*
|
||||
If the condition 'select->cond' contains a subquery, restore the
|
||||
original read/write sets of the table 'sort_form' because when
|
||||
SQL_SELECT::skip_record evaluates this condition. it may include a
|
||||
correlated subquery predicate, such that some field in the subquery
|
||||
refers to 'sort_form'.
|
||||
*/
|
||||
if (select->cond->with_subselect)
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set,
|
||||
save_vcol_set);
|
||||
write_record= (select->skip_record(thd) > 0);
|
||||
if (select->cond->with_subselect)
|
||||
sort_form->column_bitmaps_set(&sort_form->tmp_set,
|
||||
&sort_form->tmp_set,
|
||||
&sort_form->tmp_set);
|
||||
}
|
||||
else
|
||||
write_record= true;
|
||||
}
|
||||
|
||||
if (write_record)
|
||||
{
|
||||
if (idx == param->keys)
|
||||
{
|
||||
|
@ -628,7 +652,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
|||
}
|
||||
else
|
||||
file->unlock_row();
|
||||
|
||||
|
||||
/* It does not make sense to read more keys in case of a fatal error */
|
||||
if (thd->is_error())
|
||||
break;
|
||||
|
|
38
sql/item.cc
38
sql/item.cc
|
@ -387,6 +387,8 @@ Item::Item():
|
|||
decimals= 0; max_length= 0;
|
||||
with_subselect= 0;
|
||||
cmp_context= IMPOSSIBLE_RESULT;
|
||||
/* Initially this item is not attached to any JOIN_TAB. */
|
||||
join_tab_idx= MAX_TABLES;
|
||||
|
||||
/* Put item in free list so that we can free all items at end */
|
||||
THD *thd= current_thd;
|
||||
|
@ -415,6 +417,7 @@ Item::Item():
|
|||
tables.
|
||||
*/
|
||||
Item::Item(THD *thd, Item *item):
|
||||
join_tab_idx(item->join_tab_idx),
|
||||
is_expensive_cache(-1),
|
||||
rsize(0),
|
||||
str_value(item->str_value),
|
||||
|
@ -472,6 +475,7 @@ void Item::cleanup()
|
|||
DBUG_ENTER("Item::cleanup");
|
||||
fixed=0;
|
||||
marker= 0;
|
||||
join_tab_idx= MAX_TABLES;
|
||||
if (orig_name)
|
||||
name= orig_name;
|
||||
DBUG_VOID_RETURN;
|
||||
|
@ -6695,6 +6699,40 @@ bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
|
|||
}
|
||||
|
||||
|
||||
Item* Item_direct_ref_to_ident::transform(Item_transformer transformer,
|
||||
uchar *argument)
|
||||
{
|
||||
DBUG_ASSERT(!current_thd->is_stmt_prepare());
|
||||
|
||||
Item *new_item= ident->transform(transformer, argument);
|
||||
if (!new_item)
|
||||
return 0;
|
||||
DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM);
|
||||
|
||||
if (ident != new_item)
|
||||
current_thd->change_item_tree((Item**)&ident, new_item);
|
||||
return (this->*transformer)(argument);
|
||||
}
|
||||
|
||||
|
||||
Item* Item_direct_ref_to_ident::compile(Item_analyzer analyzer, uchar **arg_p,
|
||||
Item_transformer transformer,
|
||||
uchar *arg_t)
|
||||
{
|
||||
if (!(this->*analyzer)(arg_p))
|
||||
return 0;
|
||||
|
||||
uchar *arg_v= *arg_p;
|
||||
Item *new_item= ident->compile(analyzer, &arg_v, transformer, arg_t);
|
||||
if (new_item && ident != new_item)
|
||||
{
|
||||
DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM);
|
||||
current_thd->change_item_tree((Item**)&ident, new_item);
|
||||
}
|
||||
return (this->*transformer)(arg_t);
|
||||
}
|
||||
|
||||
|
||||
Item_cache_wrapper::~Item_cache_wrapper()
|
||||
{
|
||||
delete expr_cache;
|
||||
|
|
64
sql/item.h
64
sql/item.h
|
@ -491,6 +491,17 @@ typedef void (*Cond_traverser) (const Item *item, void *arg);
|
|||
class Item {
|
||||
Item(const Item &); /* Prevent use of these */
|
||||
void operator=(Item &);
|
||||
/**
|
||||
The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
|
||||
to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
|
||||
make_cond_for_table procedure. During query execution, this item is
|
||||
evaluated when the join loop reaches the corresponding JOIN_TAB.
|
||||
|
||||
If the value of join_tab_idx >= MAX_TABLES, this means that there is no
|
||||
corresponding JOIN_TAB.
|
||||
*/
|
||||
uint join_tab_idx;
|
||||
|
||||
public:
|
||||
static void *operator new(size_t size) throw ()
|
||||
{ return sql_alloc(size); }
|
||||
|
@ -507,7 +518,7 @@ public:
|
|||
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
|
||||
PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
|
||||
XPATH_NODESET, XPATH_NODESET_CMP,
|
||||
VIEW_FIXER_ITEM, EXPR_CACHE_ITEM};
|
||||
VIEW_FIXER_ITEM, EXPR_CACHE_ITEM, UNKNOWN_ITEM};
|
||||
|
||||
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
|
||||
|
||||
|
@ -608,7 +619,7 @@ public:
|
|||
virtual Item_result cast_to_int_type() const { return result_type(); }
|
||||
virtual enum_field_types string_field_type() const;
|
||||
virtual enum_field_types field_type() const;
|
||||
virtual enum Type type() const =0;
|
||||
virtual enum Type type() const { return UNKNOWN_ITEM; };
|
||||
|
||||
/*
|
||||
Return information about function monotonicity. See comment for
|
||||
|
@ -957,6 +968,8 @@ public:
|
|||
virtual bool register_field_in_read_map(uchar *arg) { return 0; }
|
||||
virtual bool enumerate_field_refs_processor(uchar *arg) { return 0; }
|
||||
virtual bool mark_as_eliminated_processor(uchar *arg) { return 0; }
|
||||
virtual bool eliminate_subselect_processor(uchar *arg) { return 0; }
|
||||
virtual bool set_fake_select_as_master_processor(uchar *arg) { return 0; }
|
||||
|
||||
/* To call bool function for all arguments */
|
||||
struct bool_func_call_args
|
||||
|
@ -1186,6 +1199,16 @@ public:
|
|||
|
||||
Item* set_expr_cache(THD *thd, List<Item*> &depends_on);
|
||||
virtual Item *get_cached_item() { return NULL; }
|
||||
/**
|
||||
Set the join tab index to the minimal (left-most) JOIN_TAB to which this
|
||||
Item is attached.
|
||||
*/
|
||||
virtual void set_join_tab_idx(uint join_tab_idx_arg)
|
||||
{
|
||||
if (join_tab_idx_arg < join_tab_idx)
|
||||
join_tab_idx= join_tab_idx_arg;
|
||||
}
|
||||
virtual uint get_join_tab_idx() { return join_tab_idx; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -2596,6 +2619,43 @@ public:
|
|||
virtual Ref_Type ref_type() { return DIRECT_REF; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
This class is the same as Item_direct_ref but created to wrap Item_ident
|
||||
before fix_fields() call
|
||||
*/
|
||||
|
||||
class Item_direct_ref_to_ident :public Item_direct_ref
|
||||
{
|
||||
Item_ident *ident;
|
||||
public:
|
||||
Item_direct_ref_to_ident(Item_ident *item)
|
||||
:Item_direct_ref(item->context, (Item**)&item, item->table_name, item->field_name,
|
||||
FALSE)
|
||||
{
|
||||
ident= item;
|
||||
ref= (Item**)&ident;
|
||||
}
|
||||
|
||||
bool fix_fields(THD *thd, Item **it)
|
||||
{
|
||||
DBUG_ASSERT(ident->type() == FIELD_ITEM || ident->type() == REF_ITEM);
|
||||
if ((!ident->fixed && ident->fix_fields(thd, ref)) ||
|
||||
ident->check_cols(1))
|
||||
return TRUE;
|
||||
set_properties();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
virtual void print(String *str, enum_query_type query_type)
|
||||
{ ident->print(str, query_type); }
|
||||
|
||||
virtual Item* transform(Item_transformer transformer, uchar *arg);
|
||||
virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
|
||||
Item_transformer transformer, uchar *arg_t);
|
||||
};
|
||||
|
||||
|
||||
class Expression_cache;
|
||||
class Item_cache;
|
||||
|
||||
|
|
|
@ -2067,6 +2067,18 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument
|
|||
}
|
||||
|
||||
|
||||
bool Item_in_optimizer::is_expensive_processor(uchar *arg)
|
||||
{
|
||||
return args[1]->is_expensive_processor(arg);
|
||||
}
|
||||
|
||||
|
||||
bool Item_in_optimizer::is_expensive()
|
||||
{
|
||||
return args[1]->is_expensive();
|
||||
}
|
||||
|
||||
|
||||
longlong Item_func_eq::val_int()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
|
@ -4732,12 +4744,6 @@ Item *and_expressions(Item *a, Item *b, Item **org_item)
|
|||
longlong Item_func_isnull::val_int()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
/*
|
||||
Handle optimization if the argument can't be null
|
||||
This has to be here because of the test in update_used_tables().
|
||||
*/
|
||||
if (!used_tables_cache && !with_subselect)
|
||||
return cached_value;
|
||||
return args[0]->is_null() ? 1: 0;
|
||||
}
|
||||
|
||||
|
@ -4745,12 +4751,6 @@ longlong Item_is_not_null_test::val_int()
|
|||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
DBUG_ENTER("Item_is_not_null_test::val_int");
|
||||
if (!used_tables_cache && !with_subselect)
|
||||
{
|
||||
owner->was_null|= (!cached_value);
|
||||
DBUG_PRINT("info", ("cached: %ld", (long) cached_value));
|
||||
DBUG_RETURN(cached_value);
|
||||
}
|
||||
if (args[0]->is_null())
|
||||
{
|
||||
DBUG_PRINT("info", ("null"));
|
||||
|
@ -4767,19 +4767,9 @@ longlong Item_is_not_null_test::val_int()
|
|||
void Item_is_not_null_test::update_used_tables()
|
||||
{
|
||||
if (!args[0]->maybe_null)
|
||||
{
|
||||
used_tables_cache= 0; /* is always true */
|
||||
cached_value= (longlong) 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
args[0]->update_used_tables();
|
||||
if (!(used_tables_cache=args[0]->used_tables()) && !with_subselect)
|
||||
{
|
||||
/* Remember if the value is always NULL or never NULL */
|
||||
cached_value= (longlong) !args[0]->is_null();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -5455,7 +5445,7 @@ Item *Item_func_nop_all::neg_transformer(THD *thd)
|
|||
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
|
||||
Item_func_not_all *new_item= new Item_func_not_all(args[0]);
|
||||
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
|
||||
allany->func= allany->func_creator(FALSE);
|
||||
allany->create_comp_func(FALSE);
|
||||
allany->all= !allany->all;
|
||||
allany->upper_item= new_item;
|
||||
return new_item;
|
||||
|
@ -5467,7 +5457,7 @@ Item *Item_func_not_all::neg_transformer(THD *thd)
|
|||
Item_func_nop_all *new_item= new Item_func_nop_all(args[0]);
|
||||
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
|
||||
allany->all= !allany->all;
|
||||
allany->func= allany->func_creator(TRUE);
|
||||
allany->create_comp_func(TRUE);
|
||||
allany->upper_item= new_item;
|
||||
return new_item;
|
||||
}
|
||||
|
@ -5751,6 +5741,9 @@ longlong Item_equal::val_int()
|
|||
Item_field *item_field;
|
||||
if (cond_false)
|
||||
return 0;
|
||||
/* If there is a single constant and no fields, the equality is TRUE. */
|
||||
if (const_item && !fields.elements)
|
||||
return 1;
|
||||
List_iterator_fast<Item_field> it(fields);
|
||||
Item *item= const_item ? const_item : it++;
|
||||
if ((null_value= item->is_null()))
|
||||
|
@ -5771,6 +5764,15 @@ longlong Item_equal::val_int()
|
|||
void Item_equal::fix_length_and_dec()
|
||||
{
|
||||
Item *item= get_first(NULL);
|
||||
if (!item)
|
||||
{
|
||||
/*
|
||||
If there are no fields, there must be at least a constant, in which
|
||||
case Item_equal::val_int evaluates to TRUE.
|
||||
*/
|
||||
DBUG_ASSERT(const_item);
|
||||
return;
|
||||
}
|
||||
eval_item= cmp_item::get_comparator(item->result_type(),
|
||||
item->collation.collation);
|
||||
}
|
||||
|
|
|
@ -266,6 +266,10 @@ public:
|
|||
void keep_top_level_cache();
|
||||
Item *transform(Item_transformer transformer, uchar *arg);
|
||||
virtual Item *expr_cache_insert_transformer(uchar *thd_arg);
|
||||
bool is_expensive_processor(uchar *arg);
|
||||
bool is_expensive();
|
||||
void set_join_tab_idx(uint join_tab_idx_arg)
|
||||
{ args[1]->set_join_tab_idx(join_tab_idx_arg); }
|
||||
};
|
||||
|
||||
class Comp_creator
|
||||
|
@ -1303,8 +1307,6 @@ public:
|
|||
|
||||
class Item_func_isnull :public Item_bool_func
|
||||
{
|
||||
protected:
|
||||
longlong cached_value;
|
||||
public:
|
||||
Item_func_isnull(Item *a) :Item_bool_func(a) {}
|
||||
longlong val_int();
|
||||
|
@ -1322,18 +1324,9 @@ public:
|
|||
{
|
||||
used_tables_cache= 0; /* is always false */
|
||||
const_item_cache= 1;
|
||||
cached_value= (longlong) 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
args[0]->update_used_tables();
|
||||
if ((const_item_cache= !(used_tables_cache= args[0]->used_tables()) &&
|
||||
!with_subselect))
|
||||
{
|
||||
/* Remember if the value is always NULL or never NULL */
|
||||
cached_value= (longlong) args[0]->is_null();
|
||||
}
|
||||
}
|
||||
}
|
||||
table_map not_null_tables() const { return 0; }
|
||||
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -71,6 +71,13 @@ protected:
|
|||
|
||||
bool inside_first_fix_fields;
|
||||
bool done_first_fix_fields;
|
||||
/*
|
||||
Set to TRUE if at optimization or execution time we determine that this
|
||||
item's value is a constant. We need this member because it is not possible
|
||||
to substitute 'this' with a constant item.
|
||||
*/
|
||||
bool forced_const;
|
||||
|
||||
public:
|
||||
/* A reference from inside subquery predicate to somewhere outside of it */
|
||||
class Ref_to_outside : public Sql_alloc
|
||||
|
@ -112,13 +119,18 @@ public:
|
|||
/* TRUE <=> The underlying SELECT is correlated w.r.t some ancestor select */
|
||||
bool is_correlated;
|
||||
|
||||
enum trans_res {RES_OK, RES_REDUCE, RES_ERROR};
|
||||
enum subs_type {UNKNOWN_SUBS, SINGLEROW_SUBS,
|
||||
EXISTS_SUBS, IN_SUBS, ALL_SUBS, ANY_SUBS};
|
||||
|
||||
Item_subselect();
|
||||
|
||||
virtual subs_type substype() { return UNKNOWN_SUBS; }
|
||||
bool is_in_predicate()
|
||||
{
|
||||
return (substype() == Item_subselect::IN_SUBS ||
|
||||
substype() == Item_subselect::ALL_SUBS ||
|
||||
substype() == Item_subselect::ANY_SUBS);
|
||||
}
|
||||
|
||||
/*
|
||||
We need this method, because some compilers do not allow 'this'
|
||||
|
@ -135,7 +147,7 @@ public:
|
|||
eliminated= FALSE;
|
||||
null_value= 1;
|
||||
}
|
||||
virtual trans_res select_transformer(JOIN *join);
|
||||
virtual bool select_transformer(JOIN *join);
|
||||
bool assigned() { return value_assigned; }
|
||||
void assigned(bool a) { value_assigned= a; }
|
||||
enum Type type() const;
|
||||
|
@ -149,12 +161,21 @@ public:
|
|||
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
|
||||
void recalc_used_tables(st_select_lex *new_parent, bool after_pullout);
|
||||
virtual bool exec();
|
||||
/*
|
||||
If subquery optimization or execution determines that the subquery has
|
||||
an empty result, mark the subquery predicate as a constant value.
|
||||
*/
|
||||
void make_const()
|
||||
{
|
||||
used_tables_cache= 0;
|
||||
const_item_cache= 0;
|
||||
forced_const= TRUE;
|
||||
}
|
||||
virtual void fix_length_and_dec();
|
||||
table_map used_tables() const;
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool const_item() const;
|
||||
inline table_map get_used_tables_cache() { return used_tables_cache; }
|
||||
inline bool get_const_item_cache() { return const_item_cache; }
|
||||
Item *get_tmp_table_item(THD *thd);
|
||||
void update_used_tables();
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
|
@ -172,6 +193,7 @@ public:
|
|||
*/
|
||||
bool is_evaluated() const;
|
||||
bool is_uncacheable() const;
|
||||
bool is_expensive() { return TRUE; }
|
||||
|
||||
/*
|
||||
Used by max/min subquery to initialize value presence registration
|
||||
|
@ -181,11 +203,23 @@ public:
|
|||
enum_parsing_place place() { return parsing_place; }
|
||||
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
|
||||
bool mark_as_eliminated_processor(uchar *arg);
|
||||
bool eliminate_subselect_processor(uchar *arg);
|
||||
bool set_fake_select_as_master_processor(uchar *arg);
|
||||
bool enumerate_field_refs_processor(uchar *arg);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("subselect");
|
||||
}
|
||||
/**
|
||||
Callback to test if an IN predicate is expensive.
|
||||
|
||||
@notes
|
||||
The return value affects the behavior of make_cond_for_table().
|
||||
|
||||
@retval TRUE if the predicate is expensive
|
||||
@retval FALSE otherwise
|
||||
*/
|
||||
bool is_expensive_processor(uchar *arg) { return TRUE; }
|
||||
Item *safe_charset_converter(CHARSET_INFO *tocs);
|
||||
|
||||
/**
|
||||
|
@ -224,7 +258,7 @@ public:
|
|||
subs_type substype() { return SINGLEROW_SUBS; }
|
||||
|
||||
void reset();
|
||||
trans_res select_transformer(JOIN *join);
|
||||
bool select_transformer(JOIN *join);
|
||||
void store(uint i, Item* item);
|
||||
double val_real();
|
||||
longlong val_int ();
|
||||
|
@ -313,6 +347,18 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
Possible methods to execute an IN predicate. These are set by the optimizer
|
||||
based on user-set optimizer switches, semantic analysis and cost comparison.
|
||||
*/
|
||||
#define SUBS_NOT_TRANSFORMED 0 /* No execution method was chosen for this IN. */
|
||||
#define SUBS_SEMI_JOIN 1 /* IN was converted to semi-join. */
|
||||
#define SUBS_IN_TO_EXISTS 2 /* IN was converted to correlated EXISTS. */
|
||||
#define SUBS_MATERIALIZATION 4 /* Execute IN via subquery materialization. */
|
||||
/* Partial matching substrategies of MATERIALIZATION. */
|
||||
#define SUBS_PARTIAL_MATCH_ROWID_MERGE 8
|
||||
#define SUBS_PARTIAL_MATCH_TABLE_SCAN 16
|
||||
|
||||
/**
|
||||
Representation of IN subquery predicates of the form
|
||||
"left_expr IN (SELECT ...)".
|
||||
|
@ -330,8 +376,6 @@ public:
|
|||
|
||||
class Item_in_subselect :public Item_exists_subselect
|
||||
{
|
||||
public:
|
||||
Item *left_expr;
|
||||
protected:
|
||||
/*
|
||||
Cache of the left operand of the subquery predicate. Allocated in the
|
||||
|
@ -339,12 +383,6 @@ protected:
|
|||
*/
|
||||
List<Cached_item> *left_expr_cache;
|
||||
bool first_execution;
|
||||
/*
|
||||
Set to TRUE if at query execution time we determine that this item's
|
||||
value is a constant during this execution. We need this member because
|
||||
it is not possible to substitute 'this' with a constant item.
|
||||
*/
|
||||
bool is_constant;
|
||||
|
||||
/*
|
||||
expr & optimizer used in subselect rewriting to store Item for
|
||||
|
@ -354,10 +392,24 @@ protected:
|
|||
Item_in_optimizer *optimizer;
|
||||
bool was_null;
|
||||
bool abort_on_null;
|
||||
public:
|
||||
/* Used to trigger on/off conditions that were pushed down to subselect */
|
||||
bool *pushed_cond_guards;
|
||||
|
||||
Comp_creator *func;
|
||||
|
||||
protected:
|
||||
bool init_cond_guards();
|
||||
bool select_in_like_transformer(JOIN *join);
|
||||
bool single_value_transformer(JOIN *join);
|
||||
bool row_value_transformer(JOIN * join);
|
||||
bool fix_having(Item *having, st_select_lex *select_lex);
|
||||
bool create_single_in_to_exists_cond(JOIN * join,
|
||||
Item **where_item,
|
||||
Item **having_item);
|
||||
bool create_row_in_to_exists_cond(JOIN * join,
|
||||
Item **where_item,
|
||||
Item **having_item);
|
||||
public:
|
||||
Item *left_expr;
|
||||
/* Priority of this predicate in the convert-to-semi-join-nest process. */
|
||||
int sj_convert_priority;
|
||||
/*
|
||||
|
@ -388,14 +440,8 @@ public:
|
|||
*/
|
||||
bool sjm_scan_allowed;
|
||||
|
||||
/* The method chosen to execute the IN predicate. */
|
||||
enum enum_exec_method {
|
||||
NOT_TRANSFORMED, /* No execution method was chosen for this IN. */
|
||||
SEMI_JOIN, /* IN was converted to semi-join nest and should be removed. */
|
||||
IN_TO_EXISTS, /* IN was converted to correlated EXISTS. */
|
||||
MATERIALIZATION /* IN will be executed via subquery materialization. */
|
||||
};
|
||||
enum_exec_method exec_method;
|
||||
/* A bitmap of possible execution strategies for an IN predicate. */
|
||||
uchar in_strategy;
|
||||
|
||||
bool *get_cond_guard(int i)
|
||||
{
|
||||
|
@ -413,9 +459,10 @@ public:
|
|||
Item_in_subselect(Item * left_expr, st_select_lex *select_lex);
|
||||
Item_in_subselect()
|
||||
:Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
|
||||
is_constant(FALSE), optimizer(0), abort_on_null(0),
|
||||
pushed_cond_guards(NULL), exec_method(NOT_TRANSFORMED), upper_item(0)
|
||||
{}
|
||||
optimizer(0), abort_on_null(0),
|
||||
pushed_cond_guards(NULL), func(NULL), in_strategy(0),
|
||||
upper_item(0)
|
||||
{}
|
||||
void cleanup();
|
||||
subs_type substype() { return IN_SUBS; }
|
||||
void reset()
|
||||
|
@ -425,13 +472,10 @@ public:
|
|||
null_value= 0;
|
||||
was_null= 0;
|
||||
}
|
||||
trans_res select_transformer(JOIN *join);
|
||||
trans_res select_in_like_transformer(JOIN *join, Comp_creator *func);
|
||||
trans_res single_value_transformer(JOIN *join, Comp_creator *func);
|
||||
trans_res row_value_transformer(JOIN * join);
|
||||
trans_res single_value_in_to_exists_transformer(JOIN * join,
|
||||
Comp_creator *func);
|
||||
trans_res row_value_in_to_exists_transformer(JOIN * join);
|
||||
bool select_transformer(JOIN *join);
|
||||
bool create_in_to_exists_cond(JOIN *join_arg);
|
||||
bool inject_in_to_exists_cond(JOIN *join_arg);
|
||||
|
||||
virtual bool exec();
|
||||
longlong val_int();
|
||||
double val_real();
|
||||
|
@ -446,11 +490,10 @@ public:
|
|||
bool fix_fields(THD *thd, Item **ref);
|
||||
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
|
||||
void update_used_tables();
|
||||
bool setup_engine();
|
||||
bool setup_mat_engine();
|
||||
bool init_left_expr_cache();
|
||||
/* Inform 'this' that it was computed, and contains a valid result. */
|
||||
void set_first_execution() { if (first_execution) first_execution= FALSE; }
|
||||
bool is_expensive_processor(uchar *arg);
|
||||
bool expr_cache_is_needed(THD *thd);
|
||||
|
||||
/*
|
||||
|
@ -472,7 +515,6 @@ class Item_allany_subselect :public Item_in_subselect
|
|||
{
|
||||
public:
|
||||
chooser_compare_func_creator func_creator;
|
||||
Comp_creator *func;
|
||||
bool all;
|
||||
|
||||
Item_allany_subselect(Item * left_expr, chooser_compare_func_creator fc,
|
||||
|
@ -480,7 +522,8 @@ public:
|
|||
|
||||
// only ALL subquery has upper not
|
||||
subs_type substype() { return all?ALL_SUBS:ANY_SUBS; }
|
||||
trans_res select_transformer(JOIN *join);
|
||||
bool select_transformer(JOIN *join);
|
||||
void create_comp_func(bool invert) { func= func_creator(invert); }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
};
|
||||
|
||||
|
@ -818,10 +861,9 @@ public:
|
|||
{}
|
||||
~subselect_hash_sj_engine();
|
||||
|
||||
bool init_permanent(List<Item> *tmp_columns);
|
||||
bool init_runtime();
|
||||
bool init(List<Item> *tmp_columns);
|
||||
void cleanup();
|
||||
int prepare() { return 0; } /* Override virtual function in base class. */
|
||||
int prepare();
|
||||
int exec();
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
uint cols()
|
||||
|
|
|
@ -1050,9 +1050,10 @@ bool Item_sum_distinct::unique_walk_function(void *element)
|
|||
void Item_sum_distinct::clear()
|
||||
{
|
||||
DBUG_ENTER("Item_sum_distinct::clear");
|
||||
DBUG_ASSERT(tree != 0); /* we always have a tree */
|
||||
/* During EXPLAIN there is no tree because it is created during execution. */
|
||||
if (tree != 0)
|
||||
tree->reset();
|
||||
null_value= 1;
|
||||
tree->reset();
|
||||
is_evaluated= FALSE;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
@ -570,26 +570,32 @@ protected:
|
|||
#define OPTIMIZER_SWITCH_FIRSTMATCH 64
|
||||
#define OPTIMIZER_SWITCH_LOOSE_SCAN 128
|
||||
#define OPTIMIZER_SWITCH_MATERIALIZATION 256
|
||||
#define OPTIMIZER_SWITCH_SEMIJOIN 512
|
||||
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE 1024
|
||||
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN (1<<11)
|
||||
#define OPTIMIZER_SWITCH_SUBQUERY_CACHE (1<<12)
|
||||
#define OPTIMIZER_SWITCH_MRR_SORT_KEYS (1<<13)
|
||||
#define OPTIMIZER_SWITCH_OUTER_JOIN_WITH_CACHE (1<<14)
|
||||
#define OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE (1<<15)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL (1<<16)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_HASHED (1<<17)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_BKA (1<<18)
|
||||
#define OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE (1<<19)
|
||||
#define OPTIMIZER_SWITCH_IN_TO_EXISTS 512
|
||||
#define OPTIMIZER_SWITCH_SEMIJOIN 1024
|
||||
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE (1<<11)
|
||||
#define OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN (1<<12)
|
||||
#define OPTIMIZER_SWITCH_SUBQUERY_CACHE (1<<13)
|
||||
#define OPTIMIZER_SWITCH_MRR_SORT_KEYS (1<<14)
|
||||
#define OPTIMIZER_SWITCH_OUTER_JOIN_WITH_CACHE (1<<15)
|
||||
#define OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE (1<<16)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL (1<<17)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_HASHED (1<<18)
|
||||
#define OPTIMIZER_SWITCH_JOIN_CACHE_BKA (1<<19)
|
||||
#define OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE (1<<20)
|
||||
#ifdef DBUG_OFF
|
||||
# define OPTIMIZER_SWITCH_LAST (1<<20)
|
||||
#else
|
||||
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<20)
|
||||
# define OPTIMIZER_SWITCH_LAST (1<<21)
|
||||
#else
|
||||
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<21)
|
||||
# define OPTIMIZER_SWITCH_LAST (1<<22)
|
||||
#endif
|
||||
|
||||
#ifdef DBUG_OFF
|
||||
/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
|
||||
/*
|
||||
TODO: Materialization is off by default to mimic 5.1/5.2 behavior.
|
||||
Once cost based choice between materialization and in-to-exists should be
|
||||
enabled by default, add OPTIMIZER_SWITCH_MATERIALIZATION
|
||||
*/
|
||||
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
|
||||
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
|
||||
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
|
||||
|
@ -597,7 +603,7 @@ protected:
|
|||
OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN | \
|
||||
OPTIMIZER_SWITCH_FIRSTMATCH | \
|
||||
OPTIMIZER_SWITCH_LOOSE_SCAN | \
|
||||
OPTIMIZER_SWITCH_MATERIALIZATION | \
|
||||
OPTIMIZER_SWITCH_IN_TO_EXISTS | \
|
||||
OPTIMIZER_SWITCH_SEMIJOIN | \
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
|
||||
|
@ -617,7 +623,7 @@ protected:
|
|||
OPTIMIZER_SWITCH_TABLE_ELIMINATION | \
|
||||
OPTIMIZER_SWITCH_FIRSTMATCH | \
|
||||
OPTIMIZER_SWITCH_LOOSE_SCAN | \
|
||||
OPTIMIZER_SWITCH_MATERIALIZATION | \
|
||||
OPTIMIZER_SWITCH_IN_TO_EXISTS | \
|
||||
OPTIMIZER_SWITCH_SEMIJOIN | \
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
|
||||
|
@ -1600,6 +1606,7 @@ inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
|
|||
}
|
||||
int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
||||
COND **conds);
|
||||
void wrap_ident(THD *thd, Item **conds);
|
||||
int setup_ftfuncs(SELECT_LEX* select);
|
||||
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
|
||||
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
|
||||
|
|
|
@ -341,7 +341,7 @@ static const char *optimizer_switch_names[]=
|
|||
"index_merge","index_merge_union","index_merge_sort_union",
|
||||
"index_merge_intersection","index_merge_sort_intersection",
|
||||
"index_condition_pushdown",
|
||||
"firstmatch","loosescan","materialization", "semijoin",
|
||||
"firstmatch","loosescan","materialization","in_to_exists","semijoin",
|
||||
"partial_match_rowid_merge",
|
||||
"partial_match_table_scan",
|
||||
"subquery_cache",
|
||||
|
@ -370,6 +370,7 @@ static const unsigned int optimizer_switch_names_len[]=
|
|||
sizeof("firstmatch") - 1,
|
||||
sizeof("loosescan") - 1,
|
||||
sizeof("materialization") - 1,
|
||||
sizeof("in_to_exists") - 1,
|
||||
sizeof("semijoin") - 1,
|
||||
sizeof("partial_match_rowid_merge") - 1,
|
||||
sizeof("partial_match_table_scan") - 1,
|
||||
|
@ -476,7 +477,8 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
|
|||
"index_condition_pushdown=on,"
|
||||
"firstmatch=on,"
|
||||
"loosescan=on,"
|
||||
"materialization=on,"
|
||||
"materialization=off,"
|
||||
"in_to_exists=on,"
|
||||
"semijoin=on,"
|
||||
"partial_match_rowid_merge=on,"
|
||||
"partial_match_table_scan=on,"
|
||||
|
@ -7410,7 +7412,7 @@ thread is in the relay logs.",
|
|||
"optimizer_switch=option=val[,option=val...], where option={index_merge, "
|
||||
"index_merge_union, index_merge_sort_union, index_merge_intersection, "
|
||||
"index_merge_sort_intersection, "
|
||||
"index_condition_pushdown, firstmatch, loosescan, materialization, "
|
||||
"index_condition_pushdown, firstmatch, loosescan, materialization, in_to_exists, "
|
||||
"semijoin, partial_match_rowid_merge, partial_match_table_scan, "
|
||||
"subquery_cache, outer_join_with_cache, semijoin_with_cache, "
|
||||
"join_cache_incremental, join_cache_hashed, join_cache_bka"
|
||||
|
|
|
@ -11102,7 +11102,7 @@ static bool get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
|
|||
uchar *key_infix, uint *key_infix_len,
|
||||
KEY_PART_INFO **first_non_infix_part);
|
||||
static bool
|
||||
check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
|
||||
check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item,
|
||||
Field::imagetype image_type);
|
||||
|
||||
static void
|
||||
|
@ -11676,13 +11676,16 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
|||
*/
|
||||
|
||||
static bool
|
||||
check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
|
||||
check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item,
|
||||
Field::imagetype image_type)
|
||||
{
|
||||
DBUG_ENTER("check_group_min_max_predicates");
|
||||
DBUG_ASSERT(cond && min_max_arg_item);
|
||||
|
||||
cond= cond->real_item();
|
||||
if (cond->get_cached_item())
|
||||
cond= cond->get_cached_item();
|
||||
|
||||
Item::Type cond_type= cond->type();
|
||||
if (cond_type == Item::COND_ITEM) /* 'AND' or 'OR' */
|
||||
{
|
||||
|
@ -11699,18 +11702,25 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
|
|||
}
|
||||
|
||||
/*
|
||||
TODO:
|
||||
This is a very crude fix to handle sub-selects in the WHERE clause
|
||||
(Item_subselect objects). With the test below we rule out from the
|
||||
optimization all queries with subselects in the WHERE clause. What has to
|
||||
be done, is that here we should analyze whether the subselect references
|
||||
the MIN/MAX argument field, and disallow the optimization only if this is
|
||||
so.
|
||||
Disallow loose index scan if the MIN/MAX argument field is referenced by
|
||||
a subquery in the WHERE clause.
|
||||
*/
|
||||
if (cond_type == Item::SUBSELECT_ITEM ||
|
||||
(cond->get_cached_item() &&
|
||||
cond->get_cached_item()->type() == Item::SUBSELECT_ITEM))
|
||||
DBUG_RETURN(FALSE);
|
||||
if (cond_type == Item::SUBSELECT_ITEM)
|
||||
{
|
||||
Item_subselect *subs_cond= (Item_subselect*) cond;
|
||||
if (subs_cond->is_correlated)
|
||||
{
|
||||
DBUG_ASSERT(subs_cond->depends_on.elements > 0);
|
||||
List_iterator_fast<Item*> li(subs_cond->depends_on);
|
||||
Item **dep;
|
||||
while ((dep= li++))
|
||||
{
|
||||
if ((*dep)->eq(min_max_arg_item, FALSE))
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
Condition of the form 'field' is equivalent to 'field <> 0' and thus
|
||||
|
|
|
@ -29,6 +29,10 @@ static TABLE_LIST *alloc_join_nest(THD *thd);
|
|||
static
|
||||
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
|
||||
static uint get_tmp_table_rec_length(List<Item> &items);
|
||||
static double get_tmp_table_lookup_cost(THD *thd, double row_count,
|
||||
uint row_size);
|
||||
static double get_tmp_table_write_cost(THD *thd, double row_count,
|
||||
uint row_size);
|
||||
bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables);
|
||||
static SJ_MATERIALIZATION_INFO *
|
||||
at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab,
|
||||
|
@ -67,6 +71,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
|||
{
|
||||
THD *thd=join->thd;
|
||||
st_select_lex *select_lex= join->select_lex;
|
||||
st_select_lex_unit* parent_unit= select_lex->master_unit();
|
||||
DBUG_ENTER("check_and_do_in_subquery_rewrites");
|
||||
/*
|
||||
If
|
||||
|
@ -84,8 +89,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
|||
TODO: for PS, make the whole block execute only on the first execution
|
||||
*/
|
||||
Item_subselect *subselect;
|
||||
if (!thd->lex->view_prepare_mode && // (1)
|
||||
(subselect= select_lex->master_unit()->item)) // (2)
|
||||
if (!thd->lex->view_prepare_mode && // (1)
|
||||
(subselect= parent_unit->item)) // (2)
|
||||
{
|
||||
Item_in_subselect *in_subs= NULL;
|
||||
if (subselect->substype() == Item_subselect::IN_SUBS)
|
||||
|
@ -129,6 +134,15 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
|||
if (failure)
|
||||
DBUG_RETURN(-1); /* purecov: deadcode */
|
||||
}
|
||||
if (select_lex == parent_unit->fake_select_lex)
|
||||
{
|
||||
/*
|
||||
The join and its select_lex object represent the 'fake' select used
|
||||
to compute the result of a UNION.
|
||||
*/
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
DBUG_PRINT("info", ("Checking if subq can be converted to semi-join"));
|
||||
/*
|
||||
Check if we're in subquery that is a candidate for flattening into a
|
||||
|
@ -154,8 +168,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
|||
!join->having && !select_lex->with_sum_func && // 4
|
||||
thd->thd_marker.emb_on_expr_nest && // 5
|
||||
select_lex->outer_select()->join && // 6
|
||||
select_lex->master_unit()->first_select()->leaf_tables && // 7
|
||||
in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED && // 8
|
||||
parent_unit->first_select()->leaf_tables && // 7
|
||||
!in_subs->in_strategy && // 8
|
||||
select_lex->outer_select()->leaf_tables && // 9
|
||||
!((join->select_options | // 10
|
||||
select_lex->outer_select()->join->select_options) // 10
|
||||
|
@ -175,63 +189,80 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
|||
else
|
||||
{
|
||||
DBUG_PRINT("info", ("Subquery can't be converted to semi-join"));
|
||||
/*
|
||||
Check if the subquery predicate can be executed via materialization.
|
||||
The required conditions are:
|
||||
1. Subquery predicate is an IN/=ANY subq predicate
|
||||
2. Subquery is a single SELECT (not a UNION)
|
||||
3. Subquery is not a table-less query. In this case there is no
|
||||
point in materializing.
|
||||
3A The upper query is not a table-less SELECT ... FROM DUAL. We
|
||||
/* Test if the user has set a legal combination of optimizer switches. */
|
||||
if (!optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) &&
|
||||
!optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION))
|
||||
my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));
|
||||
|
||||
if (in_subs)
|
||||
{
|
||||
/* Subquery predicate is an IN/=ANY predicate. */
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS))
|
||||
in_subs->in_strategy|= SUBS_IN_TO_EXISTS;
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION))
|
||||
in_subs->in_strategy|= SUBS_MATERIALIZATION;
|
||||
|
||||
/*
|
||||
Check if the subquery predicate can be executed via materialization.
|
||||
The required conditions are:
|
||||
1. Subquery is a single SELECT (not a UNION)
|
||||
2. Subquery is not a table-less query. In this case there is no
|
||||
point in materializing.
|
||||
2A The upper query is not a table-less SELECT ... FROM DUAL. We
|
||||
can't do materialization for SELECT .. FROM DUAL because it
|
||||
does not call setup_subquery_materialization(). We could make
|
||||
SELECT ... FROM DUAL call that function but that doesn't seem
|
||||
to be the case that is worth handling.
|
||||
4. Either the subquery predicate is a top-level predicate, or at
|
||||
least one partial match strategy is enabled. If no partial match
|
||||
strategy is enabled, then materialization cannot be used for
|
||||
non-top-level queries because it cannot handle NULLs correctly.
|
||||
5. Subquery is non-correlated
|
||||
TODO:
|
||||
This is an overly restrictive condition. It can be extended to:
|
||||
(Subquery is non-correlated ||
|
||||
Subquery is correlated to any query outer to IN predicate ||
|
||||
(Subquery is correlated to the immediate outer query &&
|
||||
Subquery !contains {GROUP BY, ORDER BY [LIMIT],
|
||||
aggregate functions}) && subquery predicate is not under "NOT IN"))
|
||||
6. No execution method was already chosen (by a prepared statement).
|
||||
3. Either the subquery predicate is a top-level predicate, or at
|
||||
least one partial match strategy is enabled. If no partial match
|
||||
strategy is enabled, then materialization cannot be used for
|
||||
non-top-level queries because it cannot handle NULLs correctly.
|
||||
4. Subquery is non-correlated
|
||||
TODO:
|
||||
This is an overly restrictive condition. It can be extended to:
|
||||
(Subquery is non-correlated ||
|
||||
Subquery is correlated to any query outer to IN predicate ||
|
||||
(Subquery is correlated to the immediate outer query &&
|
||||
Subquery !contains {GROUP BY, ORDER BY [LIMIT],
|
||||
aggregate functions}) && subquery predicate is not under "NOT IN"))
|
||||
|
||||
(*) The subquery must be part of a SELECT statement. The current
|
||||
condition also excludes multi-table update statements.
|
||||
(*) The subquery must be part of a SELECT statement. The current
|
||||
condition also excludes multi-table update statements.
|
||||
*/
|
||||
if (!(in_subs->in_strategy & SUBS_MATERIALIZATION &&
|
||||
!select_lex->is_part_of_union() && // 1
|
||||
parent_unit->first_select()->leaf_tables && // 2
|
||||
thd->lex->sql_command == SQLCOM_SELECT && // *
|
||||
select_lex->outer_select()->leaf_tables && // 2A
|
||||
subquery_types_allow_materialization(in_subs) &&
|
||||
// psergey-todo: duplicated_subselect_card_check: where it's done?
|
||||
(in_subs->is_top_level_item() || //3
|
||||
optimizer_flag(thd,
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) || //3
|
||||
optimizer_flag(thd,
|
||||
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) && //3
|
||||
!in_subs->is_correlated)) //4
|
||||
{
|
||||
/* Materialization is not possible based on syntactic properties. */
|
||||
in_subs->in_strategy&= ~SUBS_MATERIALIZATION;
|
||||
}
|
||||
|
||||
Determine whether we will perform subquery materialization before
|
||||
calling the IN=>EXISTS transformation, so that we know whether to
|
||||
perform the whole transformation or only that part of it which wraps
|
||||
Item_in_subselect in an Item_in_optimizer.
|
||||
if (!in_subs->in_strategy)
|
||||
{
|
||||
/*
|
||||
If neither materialization is possible, nor the user chose
|
||||
IN-TO-EXISTS, choose IN-TO-EXISTS as the only universal strategy.
|
||||
*/
|
||||
in_subs->in_strategy|= SUBS_IN_TO_EXISTS;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Transform each subquery predicate according to its overloaded
|
||||
transformer.
|
||||
*/
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) &&
|
||||
in_subs && // 1
|
||||
!select_lex->is_part_of_union() && // 2
|
||||
select_lex->master_unit()->first_select()->leaf_tables && // 3
|
||||
thd->lex->sql_command == SQLCOM_SELECT && // *
|
||||
select_lex->outer_select()->leaf_tables && // 3A
|
||||
subquery_types_allow_materialization(in_subs) &&
|
||||
// psergey-todo: duplicated_subselect_card_check: where it's done?
|
||||
(in_subs->is_top_level_item() ||
|
||||
optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) ||
|
||||
optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) &&//4
|
||||
!in_subs->is_correlated && // 5
|
||||
in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED) // 6
|
||||
{
|
||||
in_subs->exec_method= Item_in_subselect::MATERIALIZATION;
|
||||
}
|
||||
|
||||
Item_subselect::trans_res trans_res;
|
||||
if ((trans_res= subselect->select_transformer(join)) !=
|
||||
Item_subselect::RES_OK)
|
||||
{
|
||||
DBUG_RETURN((trans_res == Item_subselect::RES_ERROR));
|
||||
}
|
||||
if (subselect->select_transformer(join))
|
||||
DBUG_RETURN(-11);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
|
@ -473,18 +504,17 @@ skip_conversion:
|
|||
for (; in_subq!= in_subq_end; in_subq++)
|
||||
{
|
||||
JOIN *child_join= (*in_subq)->unit->first_select()->join;
|
||||
Item_subselect::trans_res res;
|
||||
(*in_subq)->changed= 0;
|
||||
(*in_subq)->fixed= 0;
|
||||
|
||||
SELECT_LEX *save_select_lex= thd->lex->current_select;
|
||||
thd->lex->current_select= (*in_subq)->unit->first_select();
|
||||
|
||||
res= (*in_subq)->select_transformer(child_join);
|
||||
bool res= (*in_subq)->select_transformer(child_join);
|
||||
|
||||
thd->lex->current_select= save_select_lex;
|
||||
|
||||
if (res == Item_subselect::RES_ERROR)
|
||||
if (res)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
(*in_subq)->changed= 1;
|
||||
|
@ -509,6 +539,15 @@ skip_conversion:
|
|||
FALSE))
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
Revert to the IN->EXISTS strategy in the rare case when the subquery could
|
||||
not be flattened.
|
||||
TODO: This is a limitation done for simplicity. Such subqueries could also
|
||||
be executed via materialization. In order to determine this, we should
|
||||
re-run the test for materialization that was done in
|
||||
check_and_do_in_subquery_rewrites.
|
||||
*/
|
||||
(*in_subq)->in_strategy= SUBS_IN_TO_EXISTS;
|
||||
}
|
||||
|
||||
if (arena)
|
||||
|
@ -769,8 +808,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
|||
/* 3. Remove the original subquery predicate from the WHERE/ON */
|
||||
|
||||
// The subqueries were replaced for Item_int(1) earlier
|
||||
subq_pred->exec_method=
|
||||
Item_in_subselect::SEMI_JOIN; // for subsequent executions
|
||||
subq_pred->in_strategy= SUBS_SEMI_JOIN; // for subsequent executions
|
||||
/*TODO: also reset the 'with_subselect' there. */
|
||||
|
||||
/* n. Adjust the parent_join->tables counter */
|
||||
|
@ -872,7 +910,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
|||
{
|
||||
/* Inject into the WHERE */
|
||||
parent_join->conds= and_items(parent_join->conds, sj_nest->sj_on_expr);
|
||||
save_lex= thd->lex->current_select;
|
||||
thd->lex->current_select=parent_join->select_lex;
|
||||
parent_join->conds->fix_fields(parent_join->thd, &parent_join->conds);
|
||||
thd->lex->current_select=save_lex;
|
||||
parent_join->select_lex->where= parent_join->conds;
|
||||
}
|
||||
|
||||
|
@ -1167,8 +1208,8 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
|
|||
sjm->tables= n_tables;
|
||||
sjm->is_used= FALSE;
|
||||
double subjoin_out_rows, subjoin_read_time;
|
||||
get_partial_join_cost(join, n_tables,
|
||||
&subjoin_read_time, &subjoin_out_rows);
|
||||
join->get_partial_join_cost(n_tables + join->const_tables,
|
||||
&subjoin_read_time, &subjoin_out_rows);
|
||||
|
||||
sjm->materialization_cost.convert_from_cost(subjoin_read_time);
|
||||
sjm->rows= subjoin_out_rows;
|
||||
|
@ -1216,17 +1257,16 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
|
|||
Calculate temporary table parameters and usage costs
|
||||
*/
|
||||
uint rowlen= get_tmp_table_rec_length(right_expr_list);
|
||||
double lookup_cost;
|
||||
if (rowlen * subjoin_out_rows< join->thd->variables.max_heap_table_size)
|
||||
lookup_cost= HEAP_TEMPTABLE_LOOKUP_COST;
|
||||
else
|
||||
lookup_cost= DISK_TEMPTABLE_LOOKUP_COST;
|
||||
double lookup_cost= get_tmp_table_lookup_cost(join->thd,
|
||||
subjoin_out_rows, rowlen);
|
||||
double write_cost= get_tmp_table_write_cost(join->thd,
|
||||
subjoin_out_rows, rowlen);
|
||||
|
||||
/*
|
||||
Let materialization cost include the cost to write the data into the
|
||||
temporary table:
|
||||
*/
|
||||
sjm->materialization_cost.add_io(subjoin_out_rows, lookup_cost);
|
||||
sjm->materialization_cost.add_io(subjoin_out_rows, write_cost);
|
||||
|
||||
/*
|
||||
Set the cost to do a full scan of the temptable (will need this to
|
||||
|
@ -1301,6 +1341,51 @@ static uint get_tmp_table_rec_length(List<Item> &items)
|
|||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The cost of a lookup into a unique hash/btree index on a temporary table
|
||||
with 'row_count' rows each of size 'row_size'.
|
||||
|
||||
@param thd current query context
|
||||
@param row_count number of rows in the temp table
|
||||
@param row_size average size in bytes of the rows
|
||||
|
||||
@return the cost of one lookup
|
||||
*/
|
||||
|
||||
static double
|
||||
get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size)
|
||||
{
|
||||
if (row_count * row_size > thd->variables.max_heap_table_size)
|
||||
return (double) DISK_TEMPTABLE_LOOKUP_COST;
|
||||
else
|
||||
return (double) HEAP_TEMPTABLE_LOOKUP_COST;
|
||||
}
|
||||
|
||||
/**
|
||||
The cost of writing a row into a temporary table with 'row_count' unique
|
||||
rows each of size 'row_size'.
|
||||
|
||||
@param thd current query context
|
||||
@param row_count number of rows in the temp table
|
||||
@param row_size average size in bytes of the rows
|
||||
|
||||
@return the cost of writing one row
|
||||
*/
|
||||
|
||||
static double
|
||||
get_tmp_table_write_cost(THD *thd, double row_count, uint row_size)
|
||||
{
|
||||
double lookup_cost= get_tmp_table_lookup_cost(thd, row_count, row_size);
|
||||
/*
|
||||
TODO:
|
||||
This is an optimistic estimate. Add additional costs resulting from
|
||||
actually writing the row to memory/disk and possible index reorganization.
|
||||
*/
|
||||
return lookup_cost;
|
||||
}
|
||||
|
||||
|
||||
//psergey-todo: is the below a kind of table elimination??
|
||||
/*
|
||||
Check if table's KEYUSE elements have an eq_ref(outer_tables) candidate
|
||||
|
@ -1830,15 +1915,15 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
|
|||
- sj_inner_fanout*sj_outer_fanout lookups.
|
||||
|
||||
*/
|
||||
double one_lookup_cost;
|
||||
if (sj_outer_fanout*temptable_rec_size >
|
||||
join->thd->variables.max_heap_table_size)
|
||||
one_lookup_cost= DISK_TEMPTABLE_LOOKUP_COST;
|
||||
else
|
||||
one_lookup_cost= HEAP_TEMPTABLE_LOOKUP_COST;
|
||||
double one_lookup_cost= get_tmp_table_lookup_cost(join->thd,
|
||||
sj_outer_fanout,
|
||||
temptable_rec_size);
|
||||
double one_write_cost= get_tmp_table_write_cost(join->thd,
|
||||
sj_outer_fanout,
|
||||
temptable_rec_size);
|
||||
|
||||
double write_cost= join->positions[first_tab].prefix_record_count*
|
||||
sj_outer_fanout * one_lookup_cost;
|
||||
sj_outer_fanout * one_write_cost;
|
||||
double full_lookup_cost= join->positions[first_tab].prefix_record_count*
|
||||
sj_outer_fanout* sj_inner_fanout *
|
||||
one_lookup_cost;
|
||||
|
@ -3357,9 +3442,23 @@ int rewrite_to_index_subquery_engine(JOIN *join)
|
|||
JOIN_TAB* join_tab=join->join_tab;
|
||||
SELECT_LEX_UNIT *unit= join->unit;
|
||||
DBUG_ENTER("rewrite_to_index_subquery_engine");
|
||||
|
||||
/*
|
||||
is this simple IN subquery?
|
||||
*/
|
||||
/* TODO: In order to use these more efficient subquery engines in more cases,
|
||||
the following problems need to be solved:
|
||||
- the code that removes GROUP BY (group_list), also adds an ORDER BY
|
||||
(order), thus GROUP BY queries (almost?) never pass through this branch.
|
||||
Solution: remove the test below '!join->order', because we remove the
|
||||
ORDER clase for subqueries anyway.
|
||||
- in order to set a more efficient engine, the optimizer needs to both
|
||||
decide to remove GROUP BY, *and* select one of the JT_[EQ_]REF[_OR_NULL]
|
||||
access methods, *and* loose scan should be more expensive or
|
||||
inapliccable. When is that possible?
|
||||
- Consider expanding the applicability of this rewrite for loose scan
|
||||
for group by queries.
|
||||
*/
|
||||
if (!join->group_list && !join->order &&
|
||||
join->unit->item &&
|
||||
join->unit->item->substype() == Item_subselect::IN_SUBS &&
|
||||
|
@ -3500,3 +3599,349 @@ static void remove_subq_pushed_predicates(JOIN *join, Item **where)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Optimize all subqueries of a query that have were flattened into a semijoin.
|
||||
|
||||
@details
|
||||
Optimize all immediate children subqueries of a query.
|
||||
|
||||
This phase must be called after substitute_for_best_equal_field() because
|
||||
that function may replace items with other items from a multiple equality,
|
||||
and we need to reference the correct items in the index access method of the
|
||||
IN predicate.
|
||||
|
||||
@return Operation status
|
||||
@retval FALSE success.
|
||||
@retval TRUE error occurred.
|
||||
*/
|
||||
|
||||
bool JOIN::optimize_unflattened_subqueries()
|
||||
{
|
||||
return select_lex->optimize_unflattened_subqueries();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Choose an optimal strategy to execute an IN/ALL/ANY subquery predicate
|
||||
based on cost.
|
||||
|
||||
@param join_tables the set of tables joined in the subquery
|
||||
|
||||
@notes
|
||||
The method chooses between the materialization and IN=>EXISTS rewrite
|
||||
strategies for the execution of a non-flattened subquery IN predicate.
|
||||
The cost-based decision is made as follows:
|
||||
|
||||
1. compute materialize_strategy_cost based on the unmodified subquery
|
||||
2. reoptimize the subquery taking into account the IN-EXISTS predicates
|
||||
3. compute in_exists_strategy_cost based on the reoptimized plan
|
||||
4. compare and set the cheaper strategy
|
||||
if (materialize_strategy_cost >= in_exists_strategy_cost)
|
||||
in_strategy = MATERIALIZATION
|
||||
else
|
||||
in_strategy = IN_TO_EXISTS
|
||||
5. if in_strategy = MATERIALIZATION and it is not possible to initialize it
|
||||
revert to IN_TO_EXISTS
|
||||
6. if (in_strategy == MATERIALIZATION)
|
||||
revert the subquery plan to the original one before reoptimizing
|
||||
else
|
||||
inject the IN=>EXISTS predicates into the new EXISTS subquery plan
|
||||
|
||||
The implementation itself is a bit more complicated because it takes into
|
||||
account two more factors:
|
||||
- whether the user allowed both strategies through an optimizer_switch, and
|
||||
- if materialization was the cheaper strategy, whether it can be executed
|
||||
or not.
|
||||
|
||||
@retval FALSE success.
|
||||
@retval TRUE error occurred.
|
||||
*/
|
||||
|
||||
bool JOIN::choose_subquery_plan(table_map join_tables)
|
||||
{
|
||||
Query_plan_state save_qep; /* The original QEP of the subquery. */
|
||||
enum_reopt_result reopt_result= REOPT_NONE;
|
||||
Item_in_subselect *in_subs;
|
||||
|
||||
if (select_lex->master_unit()->item &&
|
||||
select_lex->master_unit()->item->is_in_predicate())
|
||||
{
|
||||
in_subs= (Item_in_subselect*) select_lex->master_unit()->item;
|
||||
if (in_subs->create_in_to_exists_cond(this))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
DBUG_ASSERT(in_subs->in_strategy); /* A strategy must be chosen earlier. */
|
||||
DBUG_ASSERT(in_to_exists_where || in_to_exists_having);
|
||||
DBUG_ASSERT(!in_to_exists_where || in_to_exists_where->fixed);
|
||||
DBUG_ASSERT(!in_to_exists_having || in_to_exists_having->fixed);
|
||||
|
||||
/*
|
||||
Compute and compare the costs of materialization and in-exists if both
|
||||
strategies are possible and allowed by the user (checked during the prepare
|
||||
phase.
|
||||
*/
|
||||
if (in_subs->in_strategy & SUBS_MATERIALIZATION &&
|
||||
in_subs->in_strategy & SUBS_IN_TO_EXISTS)
|
||||
{
|
||||
JOIN *outer_join;
|
||||
JOIN *inner_join= this;
|
||||
/* Number of (partial) rows of the outer JOIN filtered by the IN predicate. */
|
||||
double outer_record_count;
|
||||
/* Number of unique value combinations filtered by the IN predicate. */
|
||||
double outer_lookup_keys;
|
||||
/* Cost and row count of the unmodified subquery. */
|
||||
double inner_read_time_1, inner_record_count_1;
|
||||
/* Cost of the subquery with injected IN-EXISTS predicates. */
|
||||
double inner_read_time_2;
|
||||
/* The cost to compute IN via materialization. */
|
||||
double materialize_strategy_cost;
|
||||
/* The cost of the IN->EXISTS strategy. */
|
||||
double in_exists_strategy_cost;
|
||||
double dummy;
|
||||
|
||||
/*
|
||||
A. Estimate the number of rows of the outer table that will be filtered
|
||||
by the IN predicate.
|
||||
*/
|
||||
outer_join= unit->outer_select() ? unit->outer_select()->join : NULL;
|
||||
if (outer_join)
|
||||
{
|
||||
uint outer_partial_plan_len;
|
||||
/*
|
||||
Make_cond_for_table is called for predicates only in the WHERE/ON
|
||||
clauses. In all other cases, predicates are not pushed to any
|
||||
JOIN_TAB, and their joi_tab_idx remains MAX_TABLES. Such predicates
|
||||
are evaluated for each complete row of the outer join.
|
||||
*/
|
||||
outer_partial_plan_len= (in_subs->get_join_tab_idx() == MAX_TABLES) ?
|
||||
outer_join->tables :
|
||||
in_subs->get_join_tab_idx() + 1;
|
||||
outer_join->get_partial_join_cost(outer_partial_plan_len, &dummy,
|
||||
&outer_record_count);
|
||||
if (outer_join->tables > outer_join->const_tables)
|
||||
outer_lookup_keys= prev_record_reads(outer_join->best_positions,
|
||||
outer_partial_plan_len,
|
||||
in_subs->used_tables());
|
||||
else
|
||||
{
|
||||
/* If all tables are constant, positions is undefined. */
|
||||
outer_lookup_keys= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
TODO: outer_join can be NULL for DELETE statements.
|
||||
How to compute its cost?
|
||||
*/
|
||||
outer_record_count= 1;
|
||||
outer_lookup_keys=1;
|
||||
}
|
||||
/*
|
||||
There cannot be more lookup keys than the total number of records.
|
||||
TODO: this a temporary solution until we find a better way to compute
|
||||
get_partial_join_cost() and prev_record_reads() in a consitent manner,
|
||||
where it is guaranteed that (outer_lookup_keys <= outer_record_count).
|
||||
*/
|
||||
if (outer_lookup_keys > outer_record_count)
|
||||
outer_lookup_keys= outer_record_count;
|
||||
|
||||
/*
|
||||
B. Estimate the cost and number of records of the subquery both
|
||||
unmodified, and with injected IN->EXISTS predicates.
|
||||
*/
|
||||
inner_read_time_1= inner_join->best_read;
|
||||
inner_record_count_1= inner_join->record_count;
|
||||
|
||||
if (in_to_exists_where && const_tables != tables)
|
||||
{
|
||||
/*
|
||||
Re-optimize and cost the subquery taking into account the IN-EXISTS
|
||||
conditions.
|
||||
*/
|
||||
reopt_result= reoptimize(in_to_exists_where, join_tables, &save_qep);
|
||||
if (reopt_result == REOPT_ERROR)
|
||||
return TRUE;
|
||||
|
||||
/* Get the cost of the modified IN-EXISTS plan. */
|
||||
inner_read_time_2= inner_join->best_read;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Reoptimization would not produce any better plan. */
|
||||
inner_read_time_2= inner_read_time_1;
|
||||
}
|
||||
|
||||
/*
|
||||
C. Compute execution costs.
|
||||
*/
|
||||
/* C.1 Compute the cost of the materialization strategy. */
|
||||
uint rowlen= get_tmp_table_rec_length(unit->first_select()->item_list);
|
||||
/* The cost of writing one row into the temporary table. */
|
||||
double write_cost= get_tmp_table_write_cost(thd, inner_record_count_1,
|
||||
rowlen);
|
||||
/* The cost of a lookup into the unique index of the materialized table. */
|
||||
double lookup_cost= get_tmp_table_lookup_cost(thd, inner_record_count_1,
|
||||
rowlen);
|
||||
/*
|
||||
The cost of executing the subquery and storing its result in an indexed
|
||||
temporary table.
|
||||
*/
|
||||
double materialization_cost= inner_read_time_1 +
|
||||
write_cost * inner_record_count_1;
|
||||
|
||||
materialize_strategy_cost= materialization_cost +
|
||||
outer_record_count * lookup_cost;
|
||||
|
||||
/* C.2 Compute the cost of the IN=>EXISTS strategy. */
|
||||
in_exists_strategy_cost= outer_lookup_keys * inner_read_time_2;
|
||||
|
||||
/* C.3 Compare the costs and choose the cheaper strategy. */
|
||||
if (materialize_strategy_cost >= in_exists_strategy_cost)
|
||||
in_subs->in_strategy&= ~SUBS_MATERIALIZATION;
|
||||
else
|
||||
in_subs->in_strategy&= ~SUBS_IN_TO_EXISTS;
|
||||
}
|
||||
|
||||
/*
|
||||
If (1) materialization is a possible strategy based on semantic analysis
|
||||
during the prepare phase, then if
|
||||
(2) it is more expensive than the IN->EXISTS transformation, and
|
||||
(3) it is not possible to create usable indexes for the materialization
|
||||
strategy,
|
||||
fall back to IN->EXISTS.
|
||||
otherwise
|
||||
use materialization.
|
||||
*/
|
||||
if (in_subs->in_strategy & SUBS_MATERIALIZATION &&
|
||||
in_subs->setup_mat_engine())
|
||||
{
|
||||
/*
|
||||
If materialization was the cheaper or the only user-selected strategy,
|
||||
but it is not possible to execute it due to limitations in the
|
||||
implementation, fall back to IN-TO-EXISTS.
|
||||
*/
|
||||
in_subs->in_strategy&= ~SUBS_MATERIALIZATION;
|
||||
in_subs->in_strategy|= SUBS_IN_TO_EXISTS;
|
||||
}
|
||||
|
||||
if (in_subs->in_strategy & SUBS_MATERIALIZATION)
|
||||
{
|
||||
/* Restore the original query plan used for materialization. */
|
||||
if (reopt_result == REOPT_NEW_PLAN)
|
||||
restore_query_plan(&save_qep);
|
||||
|
||||
/* TODO: should we set/unset this flag for both select_lex and its unit? */
|
||||
in_subs->unit->uncacheable&= ~UNCACHEABLE_DEPENDENT;
|
||||
select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT;
|
||||
|
||||
/*
|
||||
Reset the "LIMIT 1" set in Item_exists_subselect::fix_length_and_dec.
|
||||
TODO:
|
||||
Currently we set the subquery LIMIT to infinity, and this is correct
|
||||
because we forbid at parse time LIMIT inside IN subqueries (see
|
||||
Item_in_subselect::test_limit). However, once we allow this, here
|
||||
we should set the correct limit if given in the query.
|
||||
*/
|
||||
in_subs->unit->global_parameters->select_limit= NULL;
|
||||
in_subs->unit->set_limit(unit->global_parameters);
|
||||
/*
|
||||
Set the limit of this JOIN object as well, because normally its being
|
||||
set in the beginning of JOIN::optimize, which was already done.
|
||||
*/
|
||||
select_limit= in_subs->unit->select_limit_cnt;
|
||||
}
|
||||
else if (in_subs->in_strategy & SUBS_IN_TO_EXISTS)
|
||||
{
|
||||
if (reopt_result == REOPT_NONE && in_to_exists_where &&
|
||||
const_tables != tables)
|
||||
{
|
||||
/*
|
||||
The subquery was not reoptimized either because the user allowed only the
|
||||
IN-EXISTS strategy, or because materialization was not possible based on
|
||||
semantic analysis. Clenup the original plan and reoptimize.
|
||||
*/
|
||||
for (uint i= 0; i < tables; i++)
|
||||
{
|
||||
join_tab[i].keyuse= NULL;
|
||||
join_tab[i].checked_keys.clear_all();
|
||||
}
|
||||
if ((reopt_result= reoptimize(in_to_exists_where, join_tables, NULL)) ==
|
||||
REOPT_ERROR)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (in_subs->inject_in_to_exists_cond(this))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
DBUG_ASSERT(FALSE);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Choose a query plan for a table-less subquery.
|
||||
|
||||
@notes
|
||||
|
||||
@retval FALSE success.
|
||||
@retval TRUE error occurred.
|
||||
*/
|
||||
|
||||
bool JOIN::choose_tableless_subquery_plan()
|
||||
{
|
||||
DBUG_ASSERT(!tables_list || !tables);
|
||||
if (select_lex->master_unit()->item)
|
||||
{
|
||||
DBUG_ASSERT(select_lex->master_unit()->item->type() ==
|
||||
Item::SUBSELECT_ITEM);
|
||||
Item_subselect *subs_predicate= select_lex->master_unit()->item;
|
||||
|
||||
/*
|
||||
If the optimizer determined that his query has an empty result,
|
||||
in most cases the subquery predicate is a known constant value -
|
||||
either FALSE or NULL. The implementation of Item_subselect::reset()
|
||||
determines which one.
|
||||
*/
|
||||
if (zero_result_cause)
|
||||
{
|
||||
if (!implicit_grouping)
|
||||
{
|
||||
/*
|
||||
Both group by queries and non-group by queries without aggregate
|
||||
functions produce empty subquery result.
|
||||
*/
|
||||
subs_predicate->reset();
|
||||
subs_predicate->make_const();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
A further optimization is possible when a non-group query with
|
||||
MIN/MAX/COUNT is optimized by opt_sum_query. Then, if there are
|
||||
only MIN/MAX functions over an empty result set, the subquery
|
||||
result is a NULL value/row, thus the value of subs_predicate is
|
||||
NULL.
|
||||
*/
|
||||
}
|
||||
|
||||
if (subs_predicate->is_in_predicate())
|
||||
{
|
||||
Item_in_subselect *in_subs;
|
||||
in_subs= (Item_in_subselect*) subs_predicate;
|
||||
in_subs->in_strategy= SUBS_IN_TO_EXISTS;
|
||||
if (in_subs->create_in_to_exists_cond(this) ||
|
||||
in_subs->inject_in_to_exists_cond(this))
|
||||
return TRUE;
|
||||
tmp_having= having;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -6249,3 +6249,5 @@ ER_UNKNOWN_OPTION
|
|||
eng "Unknown option '%-.64s'"
|
||||
ER_BAD_OPTION_VALUE
|
||||
eng "Incorrect value '%-.64s' for option '%-.64s'"
|
||||
ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
|
||||
eng "At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'."
|
||||
|
|
|
@ -8121,6 +8121,29 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Wrap Item_ident
|
||||
|
||||
@param thd thread handle
|
||||
@param conds pointer to the condition which should be wrapped
|
||||
*/
|
||||
|
||||
void wrap_ident(THD *thd, Item **conds)
|
||||
{
|
||||
Item_direct_ref_to_ident *wrapper;
|
||||
DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM);
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
if (arena->is_conventional())
|
||||
arena= 0;
|
||||
else
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
if ((wrapper= new Item_direct_ref_to_ident((Item_ident *)(*conds))))
|
||||
(*conds)= (Item*) wrapper;
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Fix all conditions and outer join expressions.
|
||||
|
||||
|
@ -8184,6 +8207,12 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
|||
print_where(*conds,
|
||||
"WHERE in setup_conds",
|
||||
QT_ORDINARY););
|
||||
/*
|
||||
Wrap alone field in WHERE clause in case it will be outer field of subquery
|
||||
which need persistent pointer on it, but conds could be changed by optimizer
|
||||
*/
|
||||
if ((*conds)->type() == Item::FIELD_ITEM)
|
||||
wrap_ident(thd, conds);
|
||||
if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
|
||||
(*conds)->check_cols(1))
|
||||
goto err_no_arena;
|
||||
|
|
|
@ -2690,6 +2690,7 @@ void Query_arena::free_items()
|
|||
for (; free_list; free_list= next)
|
||||
{
|
||||
next= free_list->next;
|
||||
DBUG_ASSERT(free_list != next);
|
||||
free_list->delete_self();
|
||||
}
|
||||
/* Postcondition: free_list is 0 */
|
||||
|
@ -3133,6 +3134,7 @@ void TMP_TABLE_PARAM::init()
|
|||
table_charset= 0;
|
||||
precomputed_group_by= 0;
|
||||
bit_fields_as_long= 0;
|
||||
materialized_subquery= 0;
|
||||
skip_create_table= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
@ -2951,6 +2951,8 @@ public:
|
|||
uint convert_blob_length;
|
||||
CHARSET_INFO *table_charset;
|
||||
bool schema_table;
|
||||
/* TRUE if the temp table is created for subquery materialization. */
|
||||
bool materialized_subquery;
|
||||
/*
|
||||
True if GROUP BY and its aggregate functions are already computed
|
||||
by a table access method (e.g. by loose index scan). In this case
|
||||
|
@ -2974,8 +2976,8 @@ public:
|
|||
TMP_TABLE_PARAM()
|
||||
:copy_field(0), group_parts(0),
|
||||
group_length(0), group_null_parts(0), convert_blob_length(0),
|
||||
schema_table(0), precomputed_group_by(0), force_copy_fields(0),
|
||||
bit_fields_as_long(0), skip_create_table(0)
|
||||
schema_table(0), materialized_subquery(0), precomputed_group_by(0),
|
||||
force_copy_fields(0), bit_fields_as_long(0), skip_create_table(0)
|
||||
{}
|
||||
~TMP_TABLE_PARAM()
|
||||
{
|
||||
|
@ -3009,6 +3011,7 @@ public:
|
|||
virtual bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const char *alias, bool bit_fields_as_long);
|
||||
TMP_TABLE_PARAM *get_tmp_table_param() { return &tmp_table_param; }
|
||||
};
|
||||
|
||||
/* Base subselect interface class */
|
||||
|
@ -3072,7 +3075,7 @@ protected:
|
|||
void reset();
|
||||
|
||||
public:
|
||||
select_materialize_with_stats() {}
|
||||
select_materialize_with_stats() { tmp_table_param.init(); }
|
||||
virtual bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const char *alias, bool bit_fields_as_long);
|
||||
|
|
|
@ -93,6 +93,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||
}
|
||||
}
|
||||
|
||||
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
|
||||
if (select_lex->optimize_unflattened_subqueries())
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
const_cond= (!conds || conds->const_item());
|
||||
safe_update=test(thd->options & OPTION_SAFE_UPDATES);
|
||||
if (safe_update && const_cond)
|
||||
|
|
116
sql/sql_lex.cc
116
sql/sql_lex.cc
|
@ -1684,6 +1684,31 @@ void st_select_lex_node::include_down(st_select_lex_node *upper)
|
|||
slave= 0;
|
||||
}
|
||||
|
||||
|
||||
void st_select_lex_node::add_slave(st_select_lex_node *slave_arg)
|
||||
{
|
||||
for (; slave; slave= slave->next)
|
||||
if (slave == slave_arg)
|
||||
return;
|
||||
|
||||
if (slave)
|
||||
{
|
||||
st_select_lex_node *slave_arg_slave= slave_arg->slave;
|
||||
/* Insert in the front of list of slaves if any. */
|
||||
slave_arg->include_neighbour(slave);
|
||||
/* include_neighbour() sets slave_arg->slave=0, restore it. */
|
||||
slave_arg->slave= slave_arg_slave;
|
||||
/* Count on include_neighbour() setting the master. */
|
||||
DBUG_ASSERT(slave_arg->master == this);
|
||||
}
|
||||
else
|
||||
{
|
||||
slave= slave_arg;
|
||||
slave_arg->master= this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
include on level down (but do not link)
|
||||
|
||||
|
@ -1735,17 +1760,29 @@ void st_select_lex_node::fast_exclude()
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
excluding select_lex structure (except first (first select can't be
|
||||
Exclude a node from the tree lex structure, but leave it in the global
|
||||
list of nodes.
|
||||
*/
|
||||
|
||||
void st_select_lex_node::exclude_from_tree()
|
||||
{
|
||||
if ((*prev= next))
|
||||
next->prev= prev;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Exclude select_lex structure (except first (first select can't be
|
||||
deleted, because it is most upper select))
|
||||
*/
|
||||
void st_select_lex_node::exclude()
|
||||
{
|
||||
//exclude from global list
|
||||
/* exclude from global list */
|
||||
fast_exclude();
|
||||
//exclude from other structures
|
||||
if ((*prev= next))
|
||||
next->prev= prev;
|
||||
/* exclude from other structures */
|
||||
exclude_from_tree();
|
||||
/*
|
||||
We do not need following statements, because prev pointer of first
|
||||
list element point to master->slave
|
||||
|
@ -2145,8 +2182,8 @@ void st_select_lex::print_limit(THD *thd,
|
|||
select_limit == 1, and there should be no offset_limit.
|
||||
*/
|
||||
(((subs_type == Item_subselect::IN_SUBS) &&
|
||||
((Item_in_subselect*)item)->exec_method ==
|
||||
Item_in_subselect::MATERIALIZATION) ?
|
||||
((Item_in_subselect*)item)->in_strategy &
|
||||
SUBS_MATERIALIZATION) ?
|
||||
TRUE :
|
||||
(select_limit->val_int() == 1LL) &&
|
||||
offset_limit == 0));
|
||||
|
@ -3076,6 +3113,70 @@ bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
|
|||
str, length));
|
||||
}
|
||||
|
||||
|
||||
bool st_select_lex::optimize_unflattened_subqueries()
|
||||
{
|
||||
for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit())
|
||||
{
|
||||
Item_subselect *subquery_predicate= un->item;
|
||||
if (subquery_predicate)
|
||||
{
|
||||
for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
|
||||
{
|
||||
JOIN *inner_join= sl->join;
|
||||
SELECT_LEX *save_select= un->thd->lex->current_select;
|
||||
ulonglong save_options;
|
||||
int res;
|
||||
/* We need only 1 row to determine existence */
|
||||
un->set_limit(un->global_parameters);
|
||||
un->thd->lex->current_select= sl;
|
||||
save_options= inner_join->select_options;
|
||||
if (un->outer_select()->options & SELECT_DESCRIBE)
|
||||
{
|
||||
/* Optimize the subquery in the context of EXPLAIN. */
|
||||
set_explain_type();
|
||||
inner_join->select_options= options;
|
||||
}
|
||||
res= inner_join->optimize();
|
||||
inner_join->select_options= save_options;
|
||||
un->thd->lex->current_select= save_select;
|
||||
if (res)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the EXPLAIN type for this subquery.
|
||||
*/
|
||||
|
||||
void st_select_lex::set_explain_type()
|
||||
{
|
||||
SELECT_LEX *first= master_unit()->first_select();
|
||||
/* drop UNCACHEABLE_EXPLAIN, because it is for internal usage only */
|
||||
uint8 is_uncacheable= (uncacheable & ~UNCACHEABLE_EXPLAIN);
|
||||
|
||||
type= ((&master_unit()->thd->lex->select_lex == this) ?
|
||||
(first_inner_unit() || next_select() ?
|
||||
"PRIMARY" : "SIMPLE") :
|
||||
((this == first) ?
|
||||
((linkage == DERIVED_TABLE_TYPE) ?
|
||||
"DERIVED" :
|
||||
((is_uncacheable & UNCACHEABLE_DEPENDENT) ?
|
||||
"DEPENDENT SUBQUERY" :
|
||||
(is_uncacheable ? "UNCACHEABLE SUBQUERY" :
|
||||
"SUBQUERY"))) :
|
||||
((is_uncacheable & UNCACHEABLE_DEPENDENT) ?
|
||||
"DEPENDENT UNION":
|
||||
is_uncacheable ? "UNCACHEABLE UNION":
|
||||
"UNION")));
|
||||
options|= SELECT_DESCRIBE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
A routine used by the parser to decide whether we are specifying a full
|
||||
partitioning or if only partitions to add or to split.
|
||||
|
@ -3093,4 +3194,3 @@ bool st_lex::is_partition_management() const
|
|||
(alter_info.flags == ALTER_ADD_PARTITION ||
|
||||
alter_info.flags == ALTER_REORGANIZE_PARTITION));
|
||||
}
|
||||
|
||||
|
|
|
@ -442,10 +442,12 @@ public:
|
|||
virtual void init_query();
|
||||
virtual void init_select();
|
||||
void include_down(st_select_lex_node *upper);
|
||||
void add_slave(st_select_lex_node *slave_arg);
|
||||
void include_neighbour(st_select_lex_node *before);
|
||||
void include_standalone(st_select_lex_node *sel, st_select_lex_node **ref);
|
||||
void include_global(st_select_lex_node **plink);
|
||||
void exclude();
|
||||
void exclude_from_tree();
|
||||
|
||||
virtual st_select_lex_unit* master_unit()= 0;
|
||||
virtual st_select_lex* outer_select()= 0;
|
||||
|
@ -846,6 +848,15 @@ public:
|
|||
|
||||
void clear_index_hints(void) { index_hints= NULL; }
|
||||
bool is_part_of_union() { return master_unit()->is_union(); }
|
||||
/*
|
||||
Optimize all subqueries that have not been flattened into semi-joins.
|
||||
This functionality is a method of SELECT_LEX instead of JOIN because
|
||||
some SQL statements as DELETE do not have a corresponding JOIN object.
|
||||
*/
|
||||
bool optimize_unflattened_subqueries();
|
||||
/* Set the EXPLAIN type for this subquery. */
|
||||
void set_explain_type();
|
||||
|
||||
private:
|
||||
/* current index hint kind. used in filling up index_hints */
|
||||
enum index_hint_type current_index_hint_type;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -591,8 +591,53 @@ inline bool sj_is_materialize_strategy(uint strategy)
|
|||
|
||||
class JOIN :public Sql_alloc
|
||||
{
|
||||
private:
|
||||
JOIN(const JOIN &rhs); /**< not implemented */
|
||||
JOIN& operator=(const JOIN &rhs); /**< not implemented */
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
The subset of the state of a JOIN that represents an optimized query
|
||||
execution plan. Allows saving/restoring different plans for the same query.
|
||||
*/
|
||||
class Query_plan_state {
|
||||
public:
|
||||
DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
|
||||
POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */
|
||||
/* Copies of the JOIN_TAB::keyuse pointers for each JOIN_TAB. */
|
||||
KEYUSE *join_tab_keyuse[MAX_TABLES];
|
||||
/* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */
|
||||
key_map join_tab_checked_keys[MAX_TABLES];
|
||||
public:
|
||||
Query_plan_state()
|
||||
{
|
||||
keyuse.elements= 0;
|
||||
keyuse.buffer= NULL;
|
||||
}
|
||||
Query_plan_state(JOIN *join);
|
||||
~Query_plan_state()
|
||||
{
|
||||
delete_dynamic(&keyuse);
|
||||
}
|
||||
};
|
||||
|
||||
/* Results of reoptimizing a JOIN via JOIN::reoptimize(). */
|
||||
enum enum_reopt_result {
|
||||
REOPT_NEW_PLAN, /* there is a new reoptimized plan */
|
||||
REOPT_OLD_PLAN, /* no new improved plan can be found, use the old one */
|
||||
REOPT_ERROR, /* an irrecovarable error occured during reoptimization */
|
||||
REOPT_NONE /* not yet reoptimized */
|
||||
};
|
||||
|
||||
/* Support for plan reoptimization with rewritten conditions. */
|
||||
enum_reopt_result reoptimize(Item *added_where, table_map join_tables,
|
||||
Query_plan_state *save_to);
|
||||
void save_query_plan(Query_plan_state *save_to);
|
||||
void restore_query_plan(Query_plan_state *restore_from);
|
||||
/* Choose a subquery plan for a table-less subquery. */
|
||||
bool choose_tableless_subquery_plan();
|
||||
|
||||
public:
|
||||
JOIN_TAB *join_tab,**best_ref;
|
||||
JOIN_TAB **map2table; ///< mapping between table indexes and JOIN_TABs
|
||||
|
@ -690,6 +735,13 @@ public:
|
|||
account the changes made by test_if_skip_sort_order()).
|
||||
*/
|
||||
double best_read;
|
||||
/*
|
||||
Estimated result rows (fanout) of the whole query. If this is a subquery
|
||||
that is reexecuted multiple times, this value includes the estiamted # of
|
||||
reexecutions. This value is equal to the multiplication of all
|
||||
join->positions[i].records_read of a JOIN.
|
||||
*/
|
||||
double record_count;
|
||||
List<Item> *fields;
|
||||
List<Cached_item> group_fields, group_fields_cache;
|
||||
TABLE *tmp_table;
|
||||
|
@ -802,6 +854,19 @@ public:
|
|||
List<TABLE_LIST> *join_list; ///< list of joined tables in reverse order
|
||||
COND_EQUAL *cond_equal;
|
||||
COND_EQUAL *having_equal;
|
||||
/*
|
||||
Constant codition computed during optimization, but evaluated during
|
||||
join execution. Typically expensive conditions that should not be
|
||||
evaluated at optimization time.
|
||||
*/
|
||||
Item *exec_const_cond;
|
||||
/*
|
||||
Constant ORDER and/or GROUP expressions that contain subqueries. Such
|
||||
expressions need to evaluated to verify that the subquery indeed
|
||||
returns a single row. The evaluation of such expressions is delayed
|
||||
until query execution.
|
||||
*/
|
||||
List<Item> exec_const_order_group_cond;
|
||||
SQL_SELECT *select; ///<created in optimisation phase
|
||||
JOIN_TAB *return_tab; ///<used only for outer joins
|
||||
Item **ref_pointer_array; ///<used pointer reference for this select
|
||||
|
@ -812,8 +877,15 @@ public:
|
|||
|
||||
bool union_part; ///< this subselect is part of union
|
||||
bool optimized; ///< flag to avoid double optimization in EXPLAIN
|
||||
bool initialized; ///< flag to avoid double init_execution calls
|
||||
|
||||
Array<Item_in_subselect> sj_subselects;
|
||||
/*
|
||||
Additional WHERE and HAVING predicates to be considered for IN=>EXISTS
|
||||
subquery transformation of a JOIN object.
|
||||
*/
|
||||
Item *in_to_exists_where;
|
||||
Item *in_to_exists_having;
|
||||
|
||||
/* Temporary tables used to weed-out semi-join duplicates */
|
||||
List<TABLE> sj_tmp_tables;
|
||||
|
@ -888,8 +960,10 @@ public:
|
|||
ref_pointer_array_size= 0;
|
||||
zero_result_cause= 0;
|
||||
optimized= 0;
|
||||
initialized= 0;
|
||||
cond_equal= 0;
|
||||
having_equal= 0;
|
||||
exec_const_cond= 0;
|
||||
group_optimized_away= 0;
|
||||
no_rows_in_result_called= 0;
|
||||
|
||||
|
@ -903,6 +977,8 @@ public:
|
|||
|
||||
no_const_tables= FALSE;
|
||||
first_select= sub_select;
|
||||
in_to_exists_where= NULL;
|
||||
in_to_exists_having= NULL;
|
||||
}
|
||||
|
||||
int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,
|
||||
|
@ -911,12 +987,13 @@ public:
|
|||
SELECT_LEX_UNIT *unit);
|
||||
int optimize();
|
||||
int reinit();
|
||||
int init_execution();
|
||||
void exec();
|
||||
int destroy();
|
||||
void restore_tmp();
|
||||
bool alloc_func_list();
|
||||
bool flatten_subqueries();
|
||||
bool setup_subquery_materialization();
|
||||
bool optimize_unflattened_subqueries();
|
||||
bool make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields,
|
||||
bool before_group_by, bool recompute= FALSE);
|
||||
|
||||
|
@ -953,7 +1030,8 @@ public:
|
|||
bool send_row_on_empty_set()
|
||||
{
|
||||
return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
|
||||
!group_list && having_value != Item::COND_FALSE);
|
||||
!(group_list || group_optimized_away) &&
|
||||
having_value != Item::COND_FALSE);
|
||||
}
|
||||
bool change_result(select_result *result);
|
||||
bool is_top_level_join() const
|
||||
|
@ -985,6 +1063,9 @@ public:
|
|||
return test(allowed_join_cache_types & JOIN_CACHE_HASHED_BIT) &&
|
||||
max_allowed_join_cache_level > JOIN_CACHE_HASHED_BIT;
|
||||
}
|
||||
bool choose_subquery_plan(table_map join_tables);
|
||||
void get_partial_join_cost(uint n_tables,
|
||||
double *read_time_arg, double *record_count_arg);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -1219,6 +1300,9 @@ protected:
|
|||
if (!inited)
|
||||
{
|
||||
inited=1;
|
||||
TABLE *table= to_field->table;
|
||||
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
|
||||
table->write_set);
|
||||
if ((res= item->save_in_field(to_field, 1)))
|
||||
{
|
||||
if (!err)
|
||||
|
@ -1230,6 +1314,7 @@ protected:
|
|||
*/
|
||||
if (!err && to_field->table->in_use->is_error())
|
||||
err= 1; /* STORE_KEY_FATAL */
|
||||
dbug_tmp_restore_column_map(table->write_set, old_map);
|
||||
}
|
||||
null_key= to_field->is_null() || item->null_value;
|
||||
return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
|
||||
|
@ -1248,9 +1333,7 @@ inline Item * and_items(Item* cond, Item *item)
|
|||
{
|
||||
return (cond? (new Item_cond_and(cond, item)) : item);
|
||||
}
|
||||
bool choose_plan(JOIN *join,table_map join_tables);
|
||||
void get_partial_join_cost(JOIN *join, uint n_tables, double *read_time_arg,
|
||||
double *record_count_arg);
|
||||
bool choose_plan(JOIN *join, table_map join_tables);
|
||||
void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
|
||||
table_map last_remaining_tables,
|
||||
bool first_alt, uint no_jbuf_before,
|
||||
|
@ -1295,5 +1378,6 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
|
|||
ulonglong options);
|
||||
bool open_tmp_table(TABLE *table);
|
||||
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
|
||||
double prev_record_reads(POSITION *positions, uint idx, table_map found_ref);
|
||||
|
||||
#endif /* SQL_SELECT_INCLUDED */
|
||||
|
|
|
@ -184,6 +184,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg)
|
|||
{
|
||||
(*order->item)->walk(&Item::change_context_processor, 0,
|
||||
(uchar*) &fake_select_lex->context);
|
||||
(*order->item)->walk(&Item::set_fake_select_as_master_processor, 0,
|
||||
(uchar*) fake_select_lex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,6 +270,18 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
|
|||
|
||||
can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit);
|
||||
|
||||
/*
|
||||
Remove all references from the select_lex_units to the subqueries that
|
||||
are inside the ORDER BY clause.
|
||||
*/
|
||||
if (can_skip_order_by)
|
||||
{
|
||||
for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next)
|
||||
{
|
||||
(*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
saved_error= join->prepare(&sl->ref_pointer_array,
|
||||
sl->table_list.first,
|
||||
sl->with_wild,
|
||||
|
|
|
@ -307,6 +307,10 @@ int mysql_update(THD *thd,
|
|||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
}
|
||||
|
||||
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
|
||||
if (select_lex->optimize_unflattened_subqueries())
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (select_lex->inner_refs_list.elements &&
|
||||
fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
|
||||
DBUG_RETURN(1);
|
||||
|
|
Loading…
Reference in a new issue