1
drop table if exists t1, t2, t3, t4;
2
create table t1 (p int not null primary key, u int not null, o int not null,
3
unique (u), key(o)) engine=ndb;
4
create table t2 (p int not null primary key, u int not null, o int not null,
5
unique (u), key(o)) engine=ndb;
6
create table t3 (a int not null primary key, b int not null) engine=ndb;
7
create table t4 (c int not null primary key, d int not null) engine=ndb;
8
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
9
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
10
insert into t3 values (1,10), (2,10), (3,30), (4, 30);
11
insert into t4 values (1,10), (2,10), (3,30), (4, 30);
12
explain select * from t2 where p NOT IN (select p from t1);
13
id select_type table type possible_keys key key_len ref rows Extra
14
1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where
15
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func # Using index
16
select * from t2 where p NOT IN (select p from t1) order by p;
20
explain select * from t2 where p NOT IN (select u from t1);
21
id select_type table type possible_keys key key_len ref rows Extra
22
1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where
23
2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func # Using index
24
select * from t2 where p NOT IN (select u from t1) order by p;
28
explain select * from t2 where p NOT IN (select o from t1);
29
id select_type table type possible_keys key key_len ref rows Extra
30
1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where
31
2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func # Using index
32
select * from t2 where p NOT IN (select o from t1) order by p;
36
explain select * from t2 where p NOT IN (select p+0 from t1);
37
id select_type table type possible_keys key key_len ref rows Extra
38
1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where
39
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where
40
select * from t2 where p NOT IN (select p+0 from t1) order by p;
46
create table t1 (p int not null primary key, u int not null) engine=ndb;
47
insert into t1 values (1,1),(2,2),(3,3);
50
from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8
58
select * from t2 order by 1;
63
select * from t3 where a = any (select c from t4 where c = 1) order by a;
66
select * from t3 where a in (select c from t4 where c = 1) order by a;
69
select * from t3 where a <> some (select c from t4 where c = 1) order by a;
74
select * from t3 where a > all (select c from t4 where c = 1) order by a;
79
select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
85
select * from t3 where exists (select * from t4 where c = 1) order by a;
91
drop table if exists t1, t2, t3, t4;