Commit 0cc37246 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#90: Subqueries: Inside-out execution for non-semijoin materialized...

MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Change "SUBQUERY#n" to "<subquery{n}>" in EXPLAIN output. We need to it to be
  lowercase so that EXPLAIN results do not differ in case between systems with
  case-sensitive and case-insensitive filesystems.
- Remove garbage comments, add better comments.
parent 52faa449
...@@ -2255,8 +2255,8 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -2255,8 +2255,8 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL distinct_key NULL NULL NULL 8 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8
1 PRIMARY t1_outer ref a a 5 SUBQUERY#2.max(b) 2 Using index 1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
......
...@@ -3418,7 +3418,7 @@ EXPLAIN ...@@ -3418,7 +3418,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 1 PRIMARY t1 ALL NULL NULL NULL NULL 9
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 23 test.t1.a,test.t1.b 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 23 test.t1.a,test.t1.b 1
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
ALTER TABLE t1 ADD INDEX(a); ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a); SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
...@@ -3430,7 +3430,7 @@ EXPLAIN ...@@ -3430,7 +3430,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL a NULL NULL NULL 9 1 PRIMARY t1 ALL a NULL NULL NULL 9
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 23 test.t1.a,test.t1.b 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 23 test.t1.a,test.t1.b 1
2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
DROP TABLE t1; DROP TABLE t1;
create table t1( f1 int,f2 int); create table t1( f1 int,f2 int);
...@@ -4325,17 +4325,17 @@ INSERT INTO t1 VALUES (1),(2); ...@@ -4325,17 +4325,17 @@ INSERT INTO t1 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY SUBQUERY#2 const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY <subquery2> const distinct_key distinct_key 4 const 1 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from <materialize> (select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` where (`SUBQUERY#2`.`1` = 1) Note 1003 select 1 AS `1` from <materialize> (select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` where (`<subquery2>`.`1` = 1)
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY SUBQUERY#2 const distinct_key distinct_key 4 const 1 100.00 1 PRIMARY <subquery2> const distinct_key distinct_key 4 const 1 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from <materialize> (select 1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a`) join `test`.`t1` where (`SUBQUERY#2`.`1` = 1) Note 1003 select 1 AS `1` from <materialize> (select 1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a`) join `test`.`t1` where (`<subquery2>`.`1` = 1)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#45061: Incorrectly market field caused wrong result. # Bug#45061: Incorrectly market field caused wrong result.
......
...@@ -1017,7 +1017,7 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255; ...@@ -1017,7 +1017,7 @@ 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 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer 1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer 1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where 2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
...@@ -1035,7 +1035,7 @@ select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) a ...@@ -1035,7 +1035,7 @@ select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) a
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 2 1 PRIMARY X ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY SUBQUERY#3 eq_ref unique_key unique_key 5 func 1 2 DEPENDENT SUBQUERY <subquery3> eq_ref unique_key unique_key 5 func 1
3 SUBQUERY Z ALL NULL NULL NULL NULL 2 3 SUBQUERY Z ALL NULL NULL NULL NULL 2
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; 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 subq
...@@ -1158,7 +1158,7 @@ create table t3 ( a int , filler char(100), key(a)); ...@@ -1158,7 +1158,7 @@ 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; 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 2
1 PRIMARY t3 ref a a 5 test.t2.a 1 1 PRIMARY t3 ref a a 5 test.t2.a 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 where a in (select a from t2); select * from t3 where a in (select a from t2);
...@@ -1207,25 +1207,25 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C ...@@ -1207,25 +1207,25 @@ 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; 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 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 t1 ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t2.a 10 1 PRIMARY t3 ref a a 5 test.t2.a 10
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 1 PRIMARY A ALL NULL NULL NULL NULL 10
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer 1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.A.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.A.a 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.t2.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t2.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.t2.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t2.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
explain select straight_join * from t2 X, t2 Y explain select straight_join * from t2 X, t2 Y
...@@ -1233,7 +1233,7 @@ where X.a in (select straight_join A.a from t1 A, t1 B); ...@@ -1233,7 +1233,7 @@ 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 10 1 PRIMARY X ALL NULL NULL NULL NULL 10
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer 1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.X.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.X.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
create table t0 (a int, b int); create table t0 (a int, b int);
...@@ -1241,14 +1241,14 @@ insert into t0 values(1,1); ...@@ -1241,14 +1241,14 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1 1 PRIMARY t0 system NULL NULL NULL NULL 1
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t2.a 10 1 PRIMARY t3 ref a a 5 test.t2.a 10
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
create table t4 as select a as x, a as y from t1; 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1 1 PRIMARY t0 system NULL NULL NULL NULL 1
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where 1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where
2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
drop table t0,t1,t2,t3,t4; drop table t0,t1,t2,t3,t4;
...@@ -1274,14 +1274,14 @@ set @@optimizer_switch='firstmatch=off'; ...@@ -1274,14 +1274,14 @@ set @@optimizer_switch='firstmatch=off';
explain select * from t1 where (a,b) in (select a,b from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 10 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100 2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
set @save_optimizer_search_depth=@@optimizer_search_depth; set @save_optimizer_search_depth=@@optimizer_search_depth;
set @@optimizer_search_depth=63; set @@optimizer_search_depth=63;
explain select * from t1 where (a,b) in (select a,b from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 10 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100 2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
set @@optimizer_search_depth=@save_optimizer_search_depth; set @@optimizer_search_depth=@save_optimizer_search_depth;
set @@optimizer_switch=default; set @@optimizer_switch=default;
...@@ -1320,7 +1320,7 @@ insert into t2 select * from t2; ...@@ -1320,7 +1320,7 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 15 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 15 func 1
2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer 2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer
2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer 2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer
...@@ -1393,7 +1393,7 @@ INNER JOIN t2 c ON c.idContact=cona.idContact ...@@ -1393,7 +1393,7 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
WHERE cona.postalStripped='T2H3B2' WHERE cona.postalStripped='T2H3B2'
); );
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 2 1.00 1 PRIMARY <subquery2> 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 1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer
2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where 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 2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00
......
...@@ -1021,7 +1021,7 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255; ...@@ -1021,7 +1021,7 @@ 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 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer 1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer 1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where 2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
...@@ -1040,7 +1040,7 @@ select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) a ...@@ -1040,7 +1040,7 @@ select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) a
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 2 1 PRIMARY X ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY SUBQUERY#3 eq_ref unique_key unique_key 5 func 1 2 DEPENDENT SUBQUERY <subquery3> eq_ref unique_key unique_key 5 func 1
3 SUBQUERY Z ALL NULL NULL NULL NULL 2 3 SUBQUERY Z ALL NULL NULL NULL NULL 2
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; 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 subq
...@@ -1163,7 +1163,7 @@ create table t3 ( a int , filler char(100), key(a)); ...@@ -1163,7 +1163,7 @@ 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; 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 2
1 PRIMARY t3 ref a a 5 test.t2.a 1 Using join buffer 1 PRIMARY t3 ref a a 5 test.t2.a 1 Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 where a in (select a from t2); select * from t3 where a in (select a from t2);
...@@ -1212,25 +1212,25 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C ...@@ -1212,25 +1212,25 @@ 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; 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 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 t1 ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer 1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 1 PRIMARY A ALL NULL NULL NULL NULL 10
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer 1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.A.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.A.a 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.t2.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t2.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.t2.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t2.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
explain select straight_join * from t2 X, t2 Y explain select straight_join * from t2 X, t2 Y
...@@ -1238,7 +1238,7 @@ where X.a in (select straight_join A.a from t1 A, t1 B); ...@@ -1238,7 +1238,7 @@ 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 10 1 PRIMARY X ALL NULL NULL NULL NULL 10
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer 1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer
1 PRIMARY SUBQUERY#2 eq_ref distinct_key distinct_key 5 test.X.a 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.X.a 1
2 SUBQUERY A ALL NULL NULL NULL NULL 10 2 SUBQUERY A ALL NULL NULL NULL NULL 10
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer 2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer
create table t0 (a int, b int); create table t0 (a int, b int);
...@@ -1246,14 +1246,14 @@ insert into t0 values(1,1); ...@@ -1246,14 +1246,14 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1 1 PRIMARY t0 system NULL NULL NULL NULL 1
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer 1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
create table t4 as select a as x, a as y from t1; 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1 1 PRIMARY t0 system NULL NULL NULL NULL 1
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; Using join buffer 1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; Using join buffer
2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where 2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
drop table t0,t1,t2,t3,t4; drop table t0,t1,t2,t3,t4;
...@@ -1279,14 +1279,14 @@ set @@optimizer_switch='firstmatch=off'; ...@@ -1279,14 +1279,14 @@ set @@optimizer_switch='firstmatch=off';
explain select * from t1 where (a,b) in (select a,b from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 10 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100 2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
set @save_optimizer_search_depth=@@optimizer_search_depth; set @save_optimizer_search_depth=@@optimizer_search_depth;
set @@optimizer_search_depth=63; set @@optimizer_search_depth=63;
explain select * from t1 where (a,b) in (select a,b from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 10
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 10 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 100 2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
set @@optimizer_search_depth=@save_optimizer_search_depth; set @@optimizer_search_depth=@save_optimizer_search_depth;
set @@optimizer_switch=default; set @@optimizer_switch=default;
...@@ -1325,7 +1325,7 @@ insert into t2 select * from t2; ...@@ -1325,7 +1325,7 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 15 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 15 func 1
2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer 2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer
2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer 2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer
...@@ -1398,7 +1398,7 @@ INNER JOIN t2 c ON c.idContact=cona.idContact ...@@ -1398,7 +1398,7 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
WHERE cona.postalStripped='T2H3B2' WHERE cona.postalStripped='T2H3B2'
); );
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 2 1.00 1 PRIMARY <subquery2> 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 1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer
2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where 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 2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using join buffer
......
...@@ -216,7 +216,7 @@ FROM t2 ...@@ -216,7 +216,7 @@ FROM t2
WHERE PTYPE = 'Design')); WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5 1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
...@@ -231,13 +231,13 @@ WHERE EMPNUM IN ...@@ -231,13 +231,13 @@ WHERE EMPNUM IN
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5 1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
1 SIMPLE SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
...@@ -254,7 +254,7 @@ FROM t2 ...@@ -254,7 +254,7 @@ FROM t2
WHERE PTYPE = 'Design')); WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5 1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
...@@ -269,13 +269,13 @@ WHERE EMPNUM IN ...@@ -269,13 +269,13 @@ WHERE EMPNUM IN
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5 1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
1 SIMPLE SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
...@@ -291,7 +291,7 @@ FROM t2 ...@@ -291,7 +291,7 @@ FROM t2
WHERE PTYPE = 'Design')); WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 1 PRIMARY t1 ALL NULL NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
...@@ -306,13 +306,13 @@ WHERE EMPNUM IN ...@@ -306,13 +306,13 @@ WHERE EMPNUM IN
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 1 PRIMARY t1 ALL NULL NULL NULL NULL 5
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer 2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
......
This diff is collapsed.
...@@ -1302,7 +1302,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1302,7 +1302,7 @@ 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 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 SUBQUERY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `<subquery2>`.`a`)))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a a
2 2
...@@ -1312,7 +1312,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1312,7 +1312,7 @@ 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 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 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `<subquery2>`.`a`)))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a a
2 2
...@@ -1323,7 +1323,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1323,7 +1323,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 3 100.00 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 2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `<subquery2>`.`a`)))))
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (a int, b int, index a (a,b)); create table t1 (a int, b int, index a (a,b));
create table t2 (a int, index a (a)); create table t2 (a int, index a (a));
...@@ -1345,7 +1345,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1345,7 +1345,7 @@ 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 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 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `<subquery2>`.`a`)))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a a
2 2
...@@ -1355,7 +1355,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1355,7 +1355,7 @@ 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 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 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `<subquery2>`.`a`)))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a a
2 2
...@@ -1366,7 +1366,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1366,7 +1366,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t3 index a a 5 NULL 3 100.00 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 2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index; Using join buffer
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `<subquery2>`.`a`)))))
insert into t1 values (3,31); insert into t1 values (3,31);
select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a a
...@@ -1382,7 +1382,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1382,7 +1382,7 @@ 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 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 SUBQUERY t1 index NULL a 10 NULL 10005 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `SUBQUERY#2`.`a`))))) Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` AS `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` = `<subquery2>`.`a`)))))
drop table t0, t1, t2, t3; drop table t0, t1, t2, t3;
create table t1 (a int, b int); create table t1 (a int, b int);
create table t2 (a int, b int); create table t2 (a int, b int);
...@@ -2836,7 +2836,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -2836,7 +2836,7 @@ 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 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 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),(`test`.`t1`.`one`,`test`.`t1`.`two`) in ( <materialize> (select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `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` = `SUBQUERY#2`.`one`) and (`test`.`t1`.`two` = `SUBQUERY#2`.`two`))))) Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),(`test`.`t1`.`one`,`test`.`t1`.`two`) in ( <materialize> (select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `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` = `<subquery2>`.`one`) and (`test`.`t1`.`two` = `<subquery2>`.`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; 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 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 t1 ALL NULL NULL NULL NULL 8 100.00
...@@ -4329,13 +4329,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -4329,13 +4329,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 Using where 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 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,1 in ( <materialize> (select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `SUBQUERY#2`.`1`))))) Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,1 in ( <materialize> (select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery2>`.`1`)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); 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 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 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 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,1 in ( <materialize> (select 1 AS `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 = `SUBQUERY#2`.`1`))))) Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,1 in ( <materialize> (select 1 AS `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 = `<subquery2>`.`1`)))))
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#45061: Incorrectly market field caused wrong result. # Bug#45061: Incorrectly market field caused wrong result.
......
...@@ -848,7 +848,7 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f ...@@ -848,7 +848,7 @@ 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); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY <subquery2> 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 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
Warnings: 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`.`pk` > 0))
...@@ -1017,7 +1017,7 @@ FROM t1 ...@@ -1017,7 +1017,7 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ; WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY <subquery2> 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 2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
Warnings: 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_nokey` < '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_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
......
...@@ -32,7 +32,7 @@ a b ...@@ -32,7 +32,7 @@ a b
9 5 9 5
explain select * from t2 where b in (select a from t1); explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 3 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 3
1 PRIMARY t2 ref b b 5 test.t1.a 2 1 PRIMARY t2 ref b b 5 test.t1.a 2
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
select * from t2 where b in (select a from t1); select * from t2 where b in (select a from t1);
...@@ -74,7 +74,7 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a ...@@ -74,7 +74,7 @@ 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; from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0); explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref b b 5 test.t0.a 1 1 PRIMARY t3 ref b b 5 test.t0.a 1
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 2 SUBQUERY t0 ALL NULL NULL NULL NULL 10
set @save_ecp= @@engine_condition_pushdown; set @save_ecp= @@engine_condition_pushdown;
...@@ -101,7 +101,7 @@ set max_heap_table_size= @save_max_heap_table_size; ...@@ -101,7 +101,7 @@ set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2); explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY t2 index b b 5 NULL 10 Using index 2 SUBQUERY t2 index b b 5 NULL 10 Using index
select * from t1; select * from t1;
a b a b
...@@ -129,7 +129,7 @@ explain select ...@@ -129,7 +129,7 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 22
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer 1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer
2 SUBQUERY it ALL NULL NULL NULL NULL 22 2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
...@@ -163,7 +163,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -163,7 +163,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY it ALL NULL NULL NULL NULL 32 2 SUBQUERY it ALL NULL NULL NULL NULL 32
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
...@@ -197,7 +197,7 @@ explain select ...@@ -197,7 +197,7 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 22
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer 1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer
2 SUBQUERY it ALL NULL NULL NULL NULL 22 2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
...@@ -231,7 +231,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -231,7 +231,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY it ALL NULL NULL NULL NULL 52 2 SUBQUERY it ALL NULL NULL NULL NULL 52
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
...@@ -348,7 +348,7 @@ WHERE t1.Code IN ( ...@@ -348,7 +348,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where 2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
SELECT Name FROM t1 SELECT Name FROM t1
WHERE t1.Code IN ( WHERE t1.Code IN (
...@@ -696,7 +696,7 @@ The following must use loose index scan over t3, key a: ...@@ -696,7 +696,7 @@ The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3); 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 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 t2 index a a 5 NULL 1000 Using index
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY t3 index a a 5 NULL 30000 Using index 2 SUBQUERY t3 index a a 5 NULL 30000 Using index
select count(a) from t2 where a in ( SELECT a FROM t3); select count(a) from t2 where a in ( SELECT a FROM t3);
count(a) count(a)
......
...@@ -36,7 +36,7 @@ a b ...@@ -36,7 +36,7 @@ a b
9 5 9 5
explain select * from t2 where b in (select a from t1); explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 3 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 3
1 PRIMARY t2 ref b b 5 test.t1.a 2 Using join buffer 1 PRIMARY t2 ref b b 5 test.t1.a 2 Using join buffer
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
select * from t2 where b in (select a from t1); select * from t2 where b in (select a from t1);
...@@ -78,7 +78,7 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a ...@@ -78,7 +78,7 @@ 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; from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0); explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 10
1 PRIMARY t3 ref b b 5 test.t0.a 1 Using join buffer 1 PRIMARY t3 ref b b 5 test.t0.a 1 Using join buffer
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 2 SUBQUERY t0 ALL NULL NULL NULL NULL 10
set @save_ecp= @@engine_condition_pushdown; set @save_ecp= @@engine_condition_pushdown;
...@@ -105,7 +105,7 @@ set max_heap_table_size= @save_max_heap_table_size; ...@@ -105,7 +105,7 @@ set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2); explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY t2 index b b 5 NULL 10 Using index 2 SUBQUERY t2 index b b 5 NULL 10 Using index
select * from t1; select * from t1;
a b a b
...@@ -133,7 +133,7 @@ explain select ...@@ -133,7 +133,7 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 22
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer 1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer
2 SUBQUERY it ALL NULL NULL NULL NULL 22 2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
...@@ -167,7 +167,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -167,7 +167,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY it ALL NULL NULL NULL NULL 32 2 SUBQUERY it ALL NULL NULL NULL NULL 32
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
...@@ -201,7 +201,7 @@ explain select ...@@ -201,7 +201,7 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY SUBQUERY#2 ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 22
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer 1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer
2 SUBQUERY it ALL NULL NULL NULL NULL 22 2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
...@@ -235,7 +235,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -235,7 +235,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY it ALL NULL NULL NULL NULL 52 2 SUBQUERY it ALL NULL NULL NULL NULL 52
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
...@@ -352,7 +352,7 @@ WHERE t1.Code IN ( ...@@ -352,7 +352,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where 2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
SELECT Name FROM t1 SELECT Name FROM t1
WHERE t1.Code IN ( WHERE t1.Code IN (
...@@ -702,7 +702,7 @@ The following must use loose index scan over t3, key a: ...@@ -702,7 +702,7 @@ The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3); 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 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 t2 index a a 5 NULL 1000 Using index
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1
2 SUBQUERY t3 index a a 5 NULL 30000 Using index 2 SUBQUERY t3 index a a 5 NULL 30000 Using index
select count(a) from t2 where a in ( SELECT a FROM t3); select count(a) from t2 where a in ( SELECT a FROM t3);
count(a) count(a)
......
...@@ -852,7 +852,7 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f ...@@ -852,7 +852,7 @@ 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); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY <subquery2> 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 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
Warnings: 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`.`pk` > 0))
...@@ -1021,7 +1021,7 @@ FROM t1 ...@@ -1021,7 +1021,7 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ; WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
1 PRIMARY SUBQUERY#2 eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY <subquery2> 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 2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
Warnings: 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_nokey` < '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_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
......
This diff is collapsed.
...@@ -3710,7 +3710,7 @@ bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns, ...@@ -3710,7 +3710,7 @@ bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns,
} }
*/ */
char buf[32]; char buf[32];
uint len= my_snprintf(buf, sizeof(buf), "SUBQUERY#%d", subquery_id); uint len= my_snprintf(buf, sizeof(buf), "<subquery%d>", subquery_id);
char *name; char *name;
if (!(name= (char*)thd->alloc(len + 1))) if (!(name= (char*)thd->alloc(len + 1)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
......
...@@ -16,6 +16,136 @@ ...@@ -16,6 +16,136 @@
#include <my_bit.h> #include <my_bit.h>
/*
This file contains optimizations for semi-join subqueries.
Contents
--------
1. What is a semi-join subquery
2. General idea about semi-join execution
2.1 Correlated vs uncorrelated semi-joins
2.2 Mergeable vs non-mergeable semi-joins
3. Code-level view of semi-join processing
3.1 Conversion
3.1.1 Merged semi-join TABLE_LIST object
3.1.2 Non-merged semi-join data structure
3.2 Semi-joins and query optimization
3.3 Semi-joins and query execution
1. What is a semi-join subquery
-------------------------------
We use this definition of semi-join:
outer_tbl SEMI JOIN inner_tbl ON cond = {set of outer_tbl.row such that
exist inner_tbl.row, for which
cond(outer_tbl.row,inner_tbl.row)
is satisfied}
That is, semi-join operation is similar to inner join operation, with
exception that we don't care how many matches a row from outer_tbl has in
inner_tbl.
In SQL, that translates into following: a semi-join subquery is an IN
subquery that is an AND-part of the WHERE/ON clause.
2. General idea about semi-join execution
-----------------------------------------
We can execute semi-join in a way similar to inner join, with exception that
we need to somehow ensure that we do not generate record combinations that
differ only in rows of inner tables.
There is a number of different ways to achieve this property, implemented by
a number of semi-join execution strategies.
Some strategies can handle any semi-joins, other can be applied only to
semi-joins that have certain properties that are described below:
2.1 Correlated vs uncorrelated semi-joins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uncorrelated semi-joins are special in the respect that they allow to
- execute the subquery (possible as it's uncorrelated)
- somehow make sure that generated set does not have duplicates
- perform an inner join with outer tables.
or, rephrasing in SQL form:
SELECT ... FROM ot WHERE ot.col IN (SELECT it.col FROM it WHERE uncorr_cond)
->
SELECT ... FROM ot JOIN (SELECT DISTINCT it.col FROM it WHERE uncorr_cond)
2.2 Mergeable vs non-mergeable semi-joins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Semi-join operation has some degree of commutability with inner join
operation: we can join subquery's tables with ouside table(s) and eliminate
duplicate record combination after that:
ot1 JOIN ot2 SEMI_JOIN{it1,it2} (it1 JOIN it2) ON sjcond(ot2,it*) ->
|
+-------------------------------+
v
ot1 SEMI_JOIN{it1,it2} (it1 JOIN it2 JOIN ot2) ON sjcond(ot2,it*)
In order for this to work, subquery's top-level operation must be join, and
grouping or ordering with limit (grouping or ordering with limit are not
commutative with duplicate removal). In other words, the conversion is
possible when the subquery doesn't have GROUP BY clause, any aggregate
functions*, or ORDER BY ... LIMIT clause.
Definitions:
- Subquery whose top-level operation is a join is called *mergeable semi-join*
- All other kinds of semi-join subqueries are considered non-mergeable.
*- this requirement is actually too strong, but its exceptions are too
complicated to be considered here.
3. Code-level view of semi-join processing
------------------------------------------
3.1 Conversion
--------------
* When doing JOIN::prepare for the subquery, we detect that it can be
converted into a semi-join and register it in parent_join->sj_subselects
* At the start of parent_join->optimize(), the predicate is converted into
a semi-join node. A semi-join node is a TABLE_LIST object that is linked
somewhere in parent_join->join_list (either it is just present there, or
it is a descendant of some of its members).
There are two kinds of semi-joins:
- Merged semi-joins
- Non-merged semi-joins
3.1.1 Merged semi-join TABLE_LIST object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Merged semi-join object is a TABLE_LIST that contains a sub-join of
subquery tables and the semi-join ON expression (in this respect it is
ery similar to nested outer join representation)
Merged semi-join represents this SQL:
... SEMI JOIN (inner_tbl1 JOIN ... JOIN inner_tbl_n) ON sj_on_expr
Semi-join objects of this kind have TABLE_LIST::sj_subq_pred set.
3.1.2 Non-merged semi-join data structure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Non-merged semi-join object is a leaf TABLE_LIST object that has a subquery
that produces rows. It is similar to a base table and represents this SQL:
... SEMI_JOIN (SELECT non_mergeable_select) ON sj_on_expr
Subquery items that were converted into semi-joins are removed from the WHERE
clause. (They do remain in PS-saved WHERE clause, and they replace themselves
with Item_int(1) on subsequent re-executions).
3.2 Semi-joins and query optimization
-------------------------------------
Query optimizer operates on semi-join nests.
3.3 Semi-joins and query execution
----------------------------------
* Join executor has hooks for all semi-join strategies.
TODO elaborate
*/
static static
bool subquery_types_allow_materialization(Item_in_subselect *in_subs); bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
static bool replace_where_subcondition(JOIN *join, Item **expr, static bool replace_where_subcondition(JOIN *join, Item **expr,
...@@ -1092,7 +1222,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, ...@@ -1092,7 +1222,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
TABLE_LIST *jtbm; TABLE_LIST *jtbm;
char *tbl_alias; char *tbl_alias;
const char alias_mask[]="SUBQUERY#%d"; const char alias_mask[]="<subquery%d>";
if (!(tbl_alias= (char*)parent_join->thd->calloc(sizeof(alias_mask)+5)) || if (!(tbl_alias= (char*)parent_join->thd->calloc(sizeof(alias_mask)+5)) ||
!(jtbm= alloc_join_nest(parent_join->thd))) //todo: this is not a join nest! !(jtbm= alloc_join_nest(parent_join->thd))) //todo: this is not a join nest!
{ {
......
...@@ -5899,7 +5899,6 @@ get_best_combination(JOIN *join) ...@@ -5899,7 +5899,6 @@ get_best_combination(JOIN *join)
TABLE *form; TABLE *form;
*j= *join->best_positions[tablenr].table; *j= *join->best_positions[tablenr].table;
form=join->table[tablenr]=j->table; form=join->table[tablenr]=j->table;
//psergey-merge: or is the above: form=join->all_tables[tablenr]=j->table;
used_tables|= form->map; used_tables|= form->map;
form->reginfo.join_tab=j; form->reginfo.join_tab=j;
if (!*j->on_expr_ref) if (!*j->on_expr_ref)
...@@ -15052,8 +15051,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, ...@@ -15052,8 +15051,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
&usable_keys)) < MAX_KEY) &usable_keys)) < MAX_KEY)
{ {
/* Found key that can be used to retrieve data in sorted order */ /* Found key that can be used to retrieve data in sorted order */
//psergey-mrr:if (tab->pre_idx_push_select_cond)
// tab->select_cond= tab->select->cond= tab->pre_idx_push_select_cond;
if (tab->ref.key >= 0) if (tab->ref.key >= 0)
{ {
/* /*
...@@ -17990,7 +17987,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -17990,7 +17987,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
/* table */ /* table */
int len= my_snprintf(table_name_buffer, int len= my_snprintf(table_name_buffer,
sizeof(table_name_buffer)-1, sizeof(table_name_buffer)-1,
"SUBQUERY#%d", "<subquery%d>",
tab->emb_sj_nest->sj_subq_pred->get_identifier()); tab->emb_sj_nest->sj_subq_pred->get_identifier());
item_list.push_back(new Item_string(table_name_buffer, len, cs)); item_list.push_back(new Item_string(table_name_buffer, len, cs));
/* partitions */ /* partitions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment