mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
removing additional IN subquery condition
fixed IN optimisation bug mysql-test/r/subselect.result: test of IN optimisation bug mysql-test/t/subselect.test: test of IN optimisation bug sql/item_subselect.cc: fixed IN optimisation bug sql/mysql_priv.h: constant for additional IN subquery condition detecting sql/mysqld.cc: constant for additional IN subquery condition detecting sql/sql_select.cc: removing additional IN subquery condition
This commit is contained in:
@ -829,7 +829,7 @@ a t1.a in (select t2.a from t2)
|
||||
explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_in a a 5 func 2 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_in a a 5 func 2 Using index
|
||||
CREATE TABLE t3 (a int(11) default '0');
|
||||
INSERT INTO t3 VALUES (1),(2),(3);
|
||||
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
|
||||
@ -1369,3 +1369,26 @@ select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' fr
|
||||
s1
|
||||
tttt
|
||||
drop table t1;
|
||||
create table t1 (s1 char(5), index s1(s1));
|
||||
create table t2 (s1 char(5), index s1(s1));
|
||||
insert into t1 values ('a1'),('a2'),('a3');
|
||||
insert into t2 values ('a1'),('a2');
|
||||
select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
|
||||
s1 s1 NOT IN (SELECT s1 FROM t2)
|
||||
a1 0
|
||||
a2 0
|
||||
a3 1
|
||||
select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
|
||||
s1 s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')
|
||||
a1 0
|
||||
a2 1
|
||||
a3 1
|
||||
explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 2 Using index
|
||||
explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 1 Using index; Using where
|
||||
drop table t1,t2;
|
||||
|
@ -932,3 +932,16 @@ select (select 'a','b' from t1 union select 'a','b' from t1) from t1;
|
||||
insert into t1 values ('tttt');
|
||||
select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# IN optimisation test results
|
||||
#
|
||||
create table t1 (s1 char(5), index s1(s1));
|
||||
create table t2 (s1 char(5), index s1(s1));
|
||||
insert into t1 values ('a1'),('a2'),('a3');
|
||||
insert into t2 values ('a1'),('a2');
|
||||
select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
|
||||
select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
|
||||
explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
|
||||
explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
|
||||
drop table t1,t2;
|
||||
|
Reference in New Issue
Block a user