Commit b33826e5 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#90, code cleanup

- Unify EXPLAIN printout for <subqueryN> tables with regular tables
- Update test results for <subqueryN> tables:
  s/unique_key/distinct_key/g
  s/1.0/100.0/ for "filtered" column
parent b8fb0521
...@@ -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 <subquery2> ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort 1 PRIMARY <subquery2> ALL distinct_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 <subquery3> eq_ref unique_key unique_key 5 func 1 2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL distinct_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,7 +1207,7 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C ...@@ -1207,7 +1207,7 @@ 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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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);
...@@ -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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,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 <subquery2> eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,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 <subquery2> eq_ref unique_key unique_key 15 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 15 func,func,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 <subquery2> ALL unique_key NULL NULL NULL 2 1.00 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.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 <subquery2> ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort 1 PRIMARY <subquery2> ALL distinct_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
...@@ -1039,7 +1039,7 @@ select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) a ...@@ -1039,7 +1039,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 <subquery3> eq_ref unique_key unique_key 5 func 1 2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_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
...@@ -1162,7 +1162,7 @@ create table t3 ( a int , filler char(100), key(a)); ...@@ -1162,7 +1162,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 <subquery2> ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL distinct_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);
...@@ -1211,7 +1211,7 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C ...@@ -1211,7 +1211,7 @@ 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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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);
...@@ -1245,14 +1245,14 @@ insert into t0 values(1,1); ...@@ -1245,14 +1245,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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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;
...@@ -1278,14 +1278,14 @@ set @@optimizer_switch='firstmatch=off'; ...@@ -1278,14 +1278,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 <subquery2> eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,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 <subquery2> eq_ref unique_key unique_key 10 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,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;
...@@ -1324,7 +1324,7 @@ insert into t2 select * from t2; ...@@ -1324,7 +1324,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 <subquery2> eq_ref unique_key unique_key 15 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 15 func,func,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
...@@ -1397,7 +1397,7 @@ INNER JOIN t2 c ON c.idContact=cona.idContact ...@@ -1397,7 +1397,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 <subquery2> ALL unique_key NULL NULL NULL 2 1.00 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 SIMPLE <subquery2> eq_ref distinct_key distinct_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;
......
...@@ -1200,7 +1200,7 @@ set @save_optimizer_switch=@@optimizer_switch; ...@@ -1200,7 +1200,7 @@ set @save_optimizer_switch=@@optimizer_switch;
SET @@optimizer_switch='default,semijoin=on,materialization=on'; SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
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);
...@@ -1224,7 +1224,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on'; ...@@ -1224,7 +1224,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using MRR 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using MRR
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);
pk pk
......
...@@ -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 <subquery2> eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 13 func,func 1 100.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 <subquery2> eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.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 <subquery2> ALL unique_key NULL NULL NULL 3 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 3 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> ALL unique_key NULL NULL NULL 10 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> ALL unique_key NULL NULL NULL 22 1 PRIMARY <subquery2> ALL distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_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 <subquery2> eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 13 func,func 1 100.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 <subquery2> eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.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`))
......
...@@ -39,7 +39,7 @@ explain extended ...@@ -39,7 +39,7 @@ explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0'); select * from t1 where a1 in (select b1 from t2 where b1 > '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 3 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 9 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 9 func 1 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b1` > '0')) Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b1` > '0'))
...@@ -285,8 +285,8 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and ...@@ -285,8 +285,8 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); where (c1, c2) in (select b1, b2 from t2i where b2 > '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 3 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 func,func 1 100.00
1 PRIMARY <subquery3> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 18 func,func 1 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
3 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer 3 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer
...@@ -306,8 +306,8 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and ...@@ -306,8 +306,8 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); where (c1, c2) in (select b1, b2 from t2i where b2 > '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 t1i index it1i1,it1i2,it1i3 # # # 3 100.00 # 1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
1 PRIMARY <subquery2> eq_ref unique_key # # # 1 1.00 # 1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
1 PRIMARY <subquery3> eq_ref unique_key # # # 1 1.00 # 1 PRIMARY <subquery3> eq_ref distinct_key # # # 1 100.00 #
2 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 # 2 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
3 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 # 3 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
3 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 # 3 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 #
...@@ -329,8 +329,8 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and ...@@ -329,8 +329,8 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); where (c1, c2) in (select b1, b2 from t2i where b2 > '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 3 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 func,func 1 100.00
1 PRIMARY <subquery5> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 18 func,func 1 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
5 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer 5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer
...@@ -356,7 +356,7 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); ...@@ -356,7 +356,7 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '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 3 100.00 Start temporary 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Start temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer
1 PRIMARY <subquery5> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 18 func,func 1 100.00
5 SUBQUERY t3c ALL NULL NULL NULL NULL 4 100.00 Using where 5 SUBQUERY t3c ALL NULL NULL NULL NULL 4 100.00 Using where
5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer 5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer
4 SUBQUERY t3b ALL NULL NULL NULL NULL 4 100.00 Using where 4 SUBQUERY t3b ALL NULL NULL NULL NULL 4 100.00 Using where
...@@ -395,8 +395,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -395,8 +395,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
4 SUBQUERY t3 ALL NULL # # # 4 100.00 # 4 SUBQUERY t3 ALL NULL # # # 4 100.00 #
3 SUBQUERY t3 ALL NULL # # # 4 100.00 # 3 SUBQUERY t3 ALL NULL # # # 4 100.00 #
7 UNION t1i index it1i1,it1i2,it1i3 # # # 3 100.00 # 7 UNION t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
7 UNION <subquery8> eq_ref unique_key # # # 1 1.00 # 7 UNION <subquery8> eq_ref distinct_key # # # 1 100.00 #
7 UNION <subquery9> eq_ref unique_key # # # 1 1.00 # 7 UNION <subquery9> eq_ref distinct_key # # # 1 100.00 #
8 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 # 8 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
9 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 # 9 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
9 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 # 9 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 #
...@@ -425,7 +425,7 @@ where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where ...@@ -425,7 +425,7 @@ where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); where (c1, c2) in (select b1, b2 from t2i where b2 > '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 3 100.00 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY <subquery4> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 18 func,func 1 100.00
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer 4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
...@@ -449,7 +449,7 @@ a1 = c1; ...@@ -449,7 +449,7 @@ a1 = c1;
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 3 100.00 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer
1 PRIMARY <subquery4> eq_ref unique_key unique_key 18 func 1 1.00 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 18 func,func 1 100.00
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer 4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
...@@ -634,7 +634,7 @@ from t1_16 ...@@ -634,7 +634,7 @@ from t1_16
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); where a1 in (select substring(b1,1,16) from t2_16 where b1 > '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_16 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 20 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 20 func 1 100.00 Using where
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings: 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` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) 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` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16)))
...@@ -749,7 +749,7 @@ from t1_512 ...@@ -749,7 +749,7 @@ from t1_512
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); where a1 in (select substring(b1,1,512) from t2_512 where b1 > '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_512 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 517 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 517 func 1 100.00 Using where
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings: 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` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) 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` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512)))
...@@ -845,7 +845,7 @@ from t1_1024 ...@@ -845,7 +845,7 @@ from t1_1024
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '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_1024 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 15 func 1 1.00 1 PRIMARY <subquery2> eq_ref NULL distinct_key 15 func,func 1 100.00 Using where
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings: 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` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`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` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024)))
...@@ -939,7 +939,7 @@ from t1_1025 ...@@ -939,7 +939,7 @@ from t1_1025
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '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_1025 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 15 func 1 1.00 1 PRIMARY <subquery2> eq_ref NULL distinct_key 15 func,func 1 100.00 Using where
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings: 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` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`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` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025)))
...@@ -988,7 +988,7 @@ from t1bit ...@@ -988,7 +988,7 @@ from t1bit
where (a1, a2) in (select b1, b2 from t2bit); where (a1, a2) in (select b1, b2 from t2bit);
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 t1bit ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1bit ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <subquery2> eq_ref unique_key unique_key 10 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,func 1 100.00
2 SUBQUERY t2bit ALL NULL NULL NULL NULL 3 100.00 2 SUBQUERY t2bit ALL NULL NULL NULL NULL 3 100.00
Warnings: Warnings:
Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` semi join (`test`.`t2bit`) where 1 Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` semi join (`test`.`t2bit`) where 1
...@@ -1059,7 +1059,7 @@ insert into t3 values (30); ...@@ -1059,7 +1059,7 @@ insert into t3 values (30);
explain extended explain extended
select a from t1 where a in (select c from t2 where d >= 20); select a from t1 where a in (select c from t2 where d >= 20);
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 <subquery2> ALL unique_key NULL NULL NULL 6 1.00 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using join buffer 1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings: Warnings:
...@@ -1074,7 +1074,7 @@ create index it1a on t1(a); ...@@ -1074,7 +1074,7 @@ create index it1a on t1(a);
explain extended explain extended
select a from t1 where a in (select c from t2 where d >= 20); select a from t1 where a in (select c from t2 where d >= 20);
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 <subquery2> ALL unique_key NULL NULL NULL 6 1.00 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 100.00
1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 100.00 Using index 1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 100.00 Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings: Warnings:
...@@ -1090,7 +1090,7 @@ explain extended ...@@ -1090,7 +1090,7 @@ explain extended
select a from t1 where a in (select c from t2 where d >= 20); select a from t1 where a in (select c from t2 where d >= 20);
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 index it1a it1a 4 NULL 7 100.00 Using index 1 PRIMARY t1 index it1a it1a 4 NULL 7 100.00 Using index
1 PRIMARY <subquery2> eq_ref unique_key unique_key 4 func 1 1.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` >= 20)) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` >= 20))
...@@ -1217,7 +1217,7 @@ insert into t1 values ('aa', 'aaaa'); ...@@ -1217,7 +1217,7 @@ insert into t1 values ('aa', 'aaaa');
explain select a,b from t1 where b in (select a from t1); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY <subquery2> eq_ref unique_key unique_key 3 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1 Using where
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
select a,b from t1 where b in (select a from t1); select a,b from t1 where b in (select a from t1);
a b a b
...@@ -1238,7 +1238,7 @@ set @save_optimizer_switch=@@optimizer_switch; ...@@ -1238,7 +1238,7 @@ set @save_optimizer_switch=@@optimizer_switch;
SET @@optimizer_switch='default,semijoin=on,materialization=on'; SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL unique_key NULL NULL NULL 2 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
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);
...@@ -1262,7 +1262,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on'; ...@@ -1262,7 +1262,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY <subquery2> eq_ref unique_key unique_key 5 func 1 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using MRR 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using MRR
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);
pk pk
......
...@@ -2722,6 +2722,16 @@ bool setup_sj_materialization(JOIN_TAB *sjm_tab) ...@@ -2722,6 +2722,16 @@ bool setup_sj_materialization(JOIN_TAB *sjm_tab)
cur_ref_buff+= cur_key_part->store_length; cur_ref_buff+= cur_key_part->store_length;
} }
*ref_key= NULL; /* End marker. */ *ref_key= NULL; /* End marker. */
/*
We don't ever have guarded conditions for SJM tables, but code at SQL
layer depends on cond_guards array being alloced.
*/
if (!(tab_ref->cond_guards= (bool**) thd->calloc(sizeof(uint*)*tmp_key_parts)))
{
DBUG_RETURN(TRUE);
}
tab_ref->key_err= 1; tab_ref->key_err= 1;
tab_ref->key_parts= tmp_key_parts; tab_ref->key_parts= tmp_key_parts;
sjm->tab_ref= tab_ref; sjm->tab_ref= tab_ref;
......
...@@ -6044,12 +6044,15 @@ get_best_combination(JOIN *join) ...@@ -6044,12 +6044,15 @@ get_best_combination(JOIN *join)
j->use_join_cache= FALSE; j->use_join_cache= FALSE;
j->on_expr_ref= (Item**) &null_ptr; j->on_expr_ref= (Item**) &null_ptr;
j->cache= NULL; j->cache= NULL;
j->keys= key_map(1); // The unique index is always in 'possible keys' in EXPLAIN
/* /*
2. Proceed with processing SJM nest's join tabs, putting them into the 2. Proceed with processing SJM nest's join tabs, putting them into the
sub-order sub-order
*/ */
SJ_MATERIALIZATION_INFO *sjm= cur_pos->table->emb_sj_nest->sj_mat_info; SJ_MATERIALIZATION_INFO *sjm= cur_pos->table->emb_sj_nest->sj_mat_info;
j->records= j->records_read= sjm->is_sj_scan? sjm->rows : 1;
JOIN_TAB *jt= (JOIN_TAB*)join->thd->alloc(sizeof(JOIN_TAB) * sjm->tables); JOIN_TAB *jt= (JOIN_TAB*)join->thd->alloc(sizeof(JOIN_TAB) * sjm->tables);
JOIN_TAB_RANGE *jt_range= new JOIN_TAB_RANGE; JOIN_TAB_RANGE *jt_range= new JOIN_TAB_RANGE;
jt_range->start= jt; jt_range->start= jt;
...@@ -18337,6 +18340,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18337,6 +18340,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
join->select_lex->type; join->select_lex->type;
item_list.push_back(new Item_string(stype, strlen(stype), cs)); item_list.push_back(new Item_string(stype, strlen(stype), cs));
#if 0
/* /*
Special processing for SJ-Materialization nests: print the fake table Special processing for SJ-Materialization nests: print the fake table
and delay printing of the SJM nest contents until later. and delay printing of the SJM nest contents until later.
...@@ -18416,6 +18420,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18416,6 +18420,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
//i += join->best_positions[i].n_sj_tables-1; //i += join->best_positions[i].n_sj_tables-1;
goto loop_end; goto loop_end;
} }
#endif
if (tab->type == JT_ALL && tab->select && tab->select->quick) if (tab->type == JT_ALL && tab->select && tab->select->quick)
{ {
...@@ -18437,6 +18442,16 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18437,6 +18442,16 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
table->derived_select_number); table->derived_select_number);
item_list.push_back(new Item_string(table_name_buffer, len, cs)); item_list.push_back(new Item_string(table_name_buffer, len, cs));
} }
else if (tab->bush_children)
{
JOIN_TAB *ctab= tab->bush_children->start;
/* table */
int len= my_snprintf(table_name_buffer,
sizeof(table_name_buffer)-1,
"<subquery%d>",
ctab->emb_sj_nest->sj_subq_pred->get_identifier());
item_list.push_back(new Item_string(table_name_buffer, len, cs));
}
else else
{ {
TABLE_LIST *real_table= table->pos_in_table_list; TABLE_LIST *real_table= table->pos_in_table_list;
...@@ -18531,7 +18546,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18531,7 +18546,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
else else
{ {
if (table_list->schema_table && if (table_list && /* SJM bushes don't have table_list */
table_list->schema_table &&
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
{ {
const char *tmp_buff; const char *tmp_buff;
...@@ -18562,7 +18578,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18562,7 +18578,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
/* Add "rows" field to item_list. */ /* Add "rows" field to item_list. */
if (table_list->schema_table) if (table_list /* SJM bushes don't have table_list */ &&
table_list->schema_table)
{ {
/* in_rows */ /* in_rows */
if (join->thd->lex->describe & DESCRIBE_EXTENDED) if (join->thd->lex->describe & DESCRIBE_EXTENDED)
...@@ -18570,6 +18587,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18570,6 +18587,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
/* rows */ /* rows */
item_list.push_back(item_null); item_list.push_back(item_null);
} }
// else if (tab->bush_children)
// {
// /* psergey-todo */
// SJ_MATERIALIZATION_INFO *sjm= tab->bush_children->start->emb_sj_nest->sj_mat_info;
//
// ha_rows rows= is_scan ? ctab->emb_sj_nest->sj_mat_info->rows : 1;
// }
else else
{ {
ha_rows examined_rows; ha_rows examined_rows;
...@@ -18685,7 +18709,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18685,7 +18709,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
extra.append(STRING_WITH_LEN("; Using where")); extra.append(STRING_WITH_LEN("; Using where"));
} }
} }
if (table_list->schema_table && if (table_list /* SJM bushes don't have table_list */ &&
table_list->schema_table &&
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
{ {
if (!table_list->table_open_method) if (!table_list->table_open_method)
...@@ -18787,7 +18812,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -18787,7 +18812,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
item_list.push_back(new Item_string(str, len, cs)); item_list.push_back(new Item_string(str, len, cs));
} }
loop_end: //loop_end:
/* psergey2 /* psergey2
if (i+1 == end_table && sjm_nests_cur != sjm_nests_end) if (i+1 == end_table && sjm_nests_cur != sjm_nests_end)
{ {
......
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