1
SET debug= '+d,test_bka_unique';
2
set optimizer_switch='batched_key_access=on,mrr_cost_based=off';
3
set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off';
4
set @old_opt_switch=@@optimizer_switch;
5
set optimizer_switch='subquery_materialization_cost_based=off';
6
drop table if exists t0, t1, t2, t10, t11, t12;
7
create table t1 (a int not null, b int, primary key (a));
8
create table t2 (a int not null, primary key (a));
9
create table t3 (a int not null, b int, primary key (a));
10
insert into t1 values (1,10), (2,20), (3,30), (4,40);
11
insert into t2 values (2), (3), (4), (5);
12
insert into t3 values (10,3), (20,4), (30,5);
13
select * from t2 where t2.a in (select a from t1);
18
explain extended select * from t2 where t2.a in (select a from t1);
19
id select_type table type possible_keys key key_len ref rows filtered Extra
20
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
21
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (Block Nested Loop)
23
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)
24
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
28
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
29
id select_type table type possible_keys key key_len ref rows filtered Extra
30
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
31
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (Block Nested Loop)
33
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
34
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
38
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
39
id select_type table type possible_keys key key_len ref rows filtered Extra
40
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
41
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (Block Nested Loop)
42
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
44
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`))
45
drop table t1, t2, t3;
46
create table t1 (a int, b int, index a (a,b));
47
create table t2 (a int, index a (a));
48
create table t3 (a int, b int, index a (a));
49
insert into t1 values (1,10), (2,20), (3,30), (4,40);
50
create table t0(a int);
51
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
53
select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D;
54
insert into t2 values (2), (3), (4), (5);
55
insert into t3 values (10,3), (20,4), (30,5);
56
select * from t2 where t2.a in (select a from t1);
61
explain extended select * from t2 where t2.a in (select a from t1);
62
id select_type table type possible_keys key key_len ref rows filtered Extra
63
1 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index
64
1 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2)
66
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
67
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
71
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
72
id select_type table type possible_keys key key_len ref rows filtered Extra
73
1 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index
74
1 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
76
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
77
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
81
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
82
id select_type table type possible_keys key key_len ref rows filtered Extra
83
1 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index
84
1 SIMPLE t3 index a a 5 NULL 3 100.00 Using where; Using index
85
1 SIMPLE t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2)
87
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`))
88
insert into t1 values (3,31);
89
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
94
select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31);
98
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
99
id select_type table type possible_keys key key_len ref rows filtered Extra
100
1 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index
101
1 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
103
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
104
drop table t0, t1, t2, t3;
105
create table t0 (a int);
106
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
107
create table t1(a int, b int);
108
insert into t1 values (0,0),(1,1),(2,2);
109
create table t2 as select * from t1;
110
create table t11(a int, b int);
111
create table t10 (pk int, a int, primary key(pk));
112
insert into t10 select a,a from t0;
113
create table t12 like t10;
114
insert into t12 select * from t10;
115
Flattened because of dependency, t10=func(t1)
116
explain select * from t1 where a in (select pk from t10);
117
id select_type table type possible_keys key key_len ref rows Extra
118
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
119
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
120
select * from t1 where a in (select pk from t10);
125
A confluent case of dependency
126
explain select * from t1 where a in (select a from t10 where pk=12);
127
id select_type table type possible_keys key key_len ref rows Extra
128
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
129
select * from t1 where a in (select a from t10 where pk=12);
131
explain select * from t1 where a in (select a from t10 where pk=9);
132
id select_type table type possible_keys key key_len ref rows Extra
133
1 SIMPLE t10 const PRIMARY PRIMARY 4 const 1 NULL
134
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
135
select * from t1 where a in (select a from t10 where pk=9);
137
An empty table inside
138
explain select * from t1 where a in (select a from t11);
139
id select_type table type possible_keys key key_len ref rows Extra
140
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
141
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop)
142
2 MATERIALIZED t11 ALL NULL NULL NULL NULL 0 NULL
143
select * from t1 where a in (select a from t11);
145
explain select * from t1 where a in (select pk from t10) and b in (select pk from t10);
146
id select_type table type possible_keys key key_len ref rows Extra
147
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
148
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
149
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using index
150
select * from t1 where a in (select pk from t10) and b in (select pk from t10);
155
flattening a nested subquery
156
explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12));
157
id select_type table type possible_keys key key_len ref rows Extra
158
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
159
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using join buffer (Batched Key Access (unique))
160
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t10.a 1 Using index
161
select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12));
166
flattening subquery w/ several tables
167
explain extended select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a);
168
id select_type table type possible_keys key key_len ref rows filtered Extra
169
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
170
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access (unique))
171
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index
173
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`))
174
subqueries within outer joins go into ON expr.
176
select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10));
177
id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA
178
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 NULL
179
1 SIMPLE A ALL NULL NULL NULL NULL 3 100.00 Using where
180
1 SIMPLE B ALL NULL NULL NULL NULL 3 100.00 NULL
181
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index
183
Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`A`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`B`.`A` = `test`.`t10`.`pk`))) where 1
184
t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)"
186
select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10));
187
id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA
188
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 NULL
189
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
190
1 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t2.A 1 100.00 Using index
192
Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t2`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`t2`.`A` = `test`.`t10`.`pk`))) where 1
193
we shouldn't flatten if we're going to get a join of > MAX_TABLES.
194
explain select * from
195
t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09,
196
t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19,
197
t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29,
198
t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39,
199
t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49
203
t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09,
204
t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19
206
id select_type table type possible_keys key key_len ref rows Extra
207
1 PRIMARY s00 ALL NULL NULL NULL NULL 3 Using where
208
1 PRIMARY s01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
209
1 PRIMARY s02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
210
1 PRIMARY s03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
211
1 PRIMARY s04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
212
1 PRIMARY s05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
213
1 PRIMARY s06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
214
1 PRIMARY s07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
215
1 PRIMARY s08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
216
1 PRIMARY s09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
217
1 PRIMARY s10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
218
1 PRIMARY s11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
219
1 PRIMARY s12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
220
1 PRIMARY s13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
221
1 PRIMARY s14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
222
1 PRIMARY s15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
223
1 PRIMARY s16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
224
1 PRIMARY s17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
225
1 PRIMARY s18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
226
1 PRIMARY s19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
227
1 PRIMARY s20 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
228
1 PRIMARY s21 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
229
1 PRIMARY s22 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
230
1 PRIMARY s23 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
231
1 PRIMARY s24 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
232
1 PRIMARY s25 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
233
1 PRIMARY s26 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
234
1 PRIMARY s27 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
235
1 PRIMARY s28 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
236
1 PRIMARY s29 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
237
1 PRIMARY s30 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
238
1 PRIMARY s31 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
239
1 PRIMARY s32 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
240
1 PRIMARY s33 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
241
1 PRIMARY s34 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
242
1 PRIMARY s35 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
243
1 PRIMARY s36 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
244
1 PRIMARY s37 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
245
1 PRIMARY s38 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
246
1 PRIMARY s39 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
247
1 PRIMARY s40 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
248
1 PRIMARY s41 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
249
1 PRIMARY s42 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
250
1 PRIMARY s43 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
251
1 PRIMARY s44 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
252
1 PRIMARY s45 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
253
1 PRIMARY s46 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
254
1 PRIMARY s47 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
255
1 PRIMARY s48 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
256
1 PRIMARY s49 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
257
2 SUBQUERY m00 ALL NULL NULL NULL NULL 3 NULL
258
2 SUBQUERY m01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
259
2 SUBQUERY m02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
260
2 SUBQUERY m03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
261
2 SUBQUERY m04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
262
2 SUBQUERY m05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
263
2 SUBQUERY m06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
264
2 SUBQUERY m07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
265
2 SUBQUERY m08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
266
2 SUBQUERY m09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
267
2 SUBQUERY m10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
268
2 SUBQUERY m11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
269
2 SUBQUERY m12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
270
2 SUBQUERY m13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
271
2 SUBQUERY m14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
272
2 SUBQUERY m15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
273
2 SUBQUERY m16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
274
2 SUBQUERY m17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
275
2 SUBQUERY m18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
276
2 SUBQUERY m19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop)
278
t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10))
286
t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10))
298
insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B;
299
explain extended select * from t1 where a in (select pk from t10 where pk<3);
300
id select_type table type possible_keys key key_len ref rows filtered Extra
301
1 SIMPLE t10 range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index
302
1 SIMPLE t1 ALL NULL NULL NULL NULL 103 100.00 Using where; Using join buffer (Block Nested Loop)
304
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3))
305
drop table t0, t1, t2;
306
drop table t10, t11, t12;
308
# Check that subqueries with outer joins or straight_join work for
309
# different permutations of const and non-const tables. (Ref. Bug#46692)
311
CREATE TABLE t1 (i INTEGER);
312
CREATE TABLE t2 (i INTEGER);
313
CREATE TABLE t3 (i INTEGER);
314
SELECT (SELECT COUNT(*) from t1) AS c1,
315
(SELECT COUNT(*) from t2) AS c2,
316
(SELECT COUNT(*) from t3) AS c3;
319
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
320
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
321
id select_type table type possible_keys key key_len ref rows Extra
322
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
323
SELECT * FROM t1 WHERE (t1.i) IN
324
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
326
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
327
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
332
DEALLOCATE PREPARE stmt;
333
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
334
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
335
id select_type table type possible_keys key key_len ref rows Extra
336
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
337
SELECT * FROM t1 WHERE (t1.i) IN
338
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
340
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
341
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
346
DEALLOCATE PREPARE stmt;
347
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
348
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
349
id select_type table type possible_keys key key_len ref rows Extra
350
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
351
SELECT * FROM t1 WHERE (t1.i) IN
352
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
354
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
355
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
356
id select_type table type possible_keys key key_len ref rows Extra
357
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
358
SELECT * FROM t1 WHERE (t1.i) IN
359
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
361
EXPLAIN SELECT * FROM t1 WHERE (11) IN
362
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
363
id select_type table type possible_keys key key_len ref rows Extra
364
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
365
SELECT * FROM t1 WHERE (11) IN
366
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
368
EXPLAIN SELECT * FROM t1 WHERE (11) IN
369
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
370
id select_type table type possible_keys key key_len ref rows Extra
371
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
372
SELECT * FROM t1 WHERE (11) IN
373
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
375
EXPLAIN SELECT * FROM t1 WHERE (11) IN
376
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
377
id select_type table type possible_keys key key_len ref rows Extra
378
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
379
SELECT * FROM t1 WHERE (11) IN
380
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
382
EXPLAIN SELECT * FROM t1 WHERE (11) IN
383
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
384
id select_type table type possible_keys key key_len ref rows Extra
385
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
386
SELECT * FROM t1 WHERE (11) IN
387
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
389
INSERT INTO t3 VALUES (2);
390
SELECT (SELECT COUNT(*) from t1) AS c1,
391
(SELECT COUNT(*) from t2) AS c2,
392
(SELECT COUNT(*) from t3) AS c3;
395
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
396
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
397
id select_type table type possible_keys key key_len ref rows Extra
398
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
399
SELECT * FROM t1 WHERE (t1.i) IN
400
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
402
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
403
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
408
DEALLOCATE PREPARE stmt;
409
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
410
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
411
id select_type table type possible_keys key key_len ref rows Extra
412
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
413
SELECT * FROM t1 WHERE (t1.i) IN
414
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
416
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
417
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
422
DEALLOCATE PREPARE stmt;
423
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
424
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
425
id select_type table type possible_keys key key_len ref rows Extra
426
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
427
SELECT * FROM t1 WHERE (t1.i) IN
428
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
430
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
431
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
432
id select_type table type possible_keys key key_len ref rows Extra
433
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
434
SELECT * FROM t1 WHERE (t1.i) IN
435
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
437
EXPLAIN SELECT * FROM t1 WHERE (11) IN
438
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
439
id select_type table type possible_keys key key_len ref rows Extra
440
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
441
SELECT * FROM t1 WHERE (11) IN
442
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
444
EXPLAIN SELECT * FROM t1 WHERE (11) IN
445
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
446
id select_type table type possible_keys key key_len ref rows Extra
447
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
448
SELECT * FROM t1 WHERE (11) IN
449
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
451
EXPLAIN SELECT * FROM t1 WHERE (11) IN
452
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
453
id select_type table type possible_keys key key_len ref rows Extra
454
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
455
SELECT * FROM t1 WHERE (11) IN
456
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
458
EXPLAIN SELECT * FROM t1 WHERE (11) IN
459
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
460
id select_type table type possible_keys key key_len ref rows Extra
461
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
462
SELECT * FROM t1 WHERE (11) IN
463
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
465
INSERT INTO t3 VALUES (1);
466
SELECT (SELECT COUNT(*) from t1) AS c1,
467
(SELECT COUNT(*) from t2) AS c2,
468
(SELECT COUNT(*) from t3) AS c3;
471
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
472
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
473
id select_type table type possible_keys key key_len ref rows Extra
474
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
475
SELECT * FROM t1 WHERE (t1.i) IN
476
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
478
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
479
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
484
DEALLOCATE PREPARE stmt;
485
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
486
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
487
id select_type table type possible_keys key key_len ref rows Extra
488
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
489
SELECT * FROM t1 WHERE (t1.i) IN
490
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
492
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
493
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
498
DEALLOCATE PREPARE stmt;
499
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
500
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
501
id select_type table type possible_keys key key_len ref rows Extra
502
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
503
SELECT * FROM t1 WHERE (t1.i) IN
504
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
506
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
507
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
508
id select_type table type possible_keys key key_len ref rows Extra
509
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
510
SELECT * FROM t1 WHERE (t1.i) IN
511
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
513
EXPLAIN SELECT * FROM t1 WHERE (11) IN
514
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
515
id select_type table type possible_keys key key_len ref rows Extra
516
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
517
SELECT * FROM t1 WHERE (11) IN
518
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
520
EXPLAIN SELECT * FROM t1 WHERE (11) IN
521
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
522
id select_type table type possible_keys key key_len ref rows Extra
523
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
524
SELECT * FROM t1 WHERE (11) IN
525
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
527
EXPLAIN SELECT * FROM t1 WHERE (11) IN
528
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
529
id select_type table type possible_keys key key_len ref rows Extra
530
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
531
SELECT * FROM t1 WHERE (11) IN
532
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
534
EXPLAIN SELECT * FROM t1 WHERE (11) IN
535
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
536
id select_type table type possible_keys key key_len ref rows Extra
537
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
538
SELECT * FROM t1 WHERE (11) IN
539
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
541
INSERT INTO t3 VALUES (0);
543
INSERT INTO t2 VALUES (2);
544
SELECT (SELECT COUNT(*) from t1) AS c1,
545
(SELECT COUNT(*) from t2) AS c2,
546
(SELECT COUNT(*) from t3) AS c3;
549
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
550
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
551
id select_type table type possible_keys key key_len ref rows Extra
552
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
553
SELECT * FROM t1 WHERE (t1.i) IN
554
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
556
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
557
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
562
DEALLOCATE PREPARE stmt;
563
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
564
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
565
id select_type table type possible_keys key key_len ref rows Extra
566
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
567
SELECT * FROM t1 WHERE (t1.i) IN
568
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
570
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
571
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
576
DEALLOCATE PREPARE stmt;
577
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
578
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
579
id select_type table type possible_keys key key_len ref rows Extra
580
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
581
SELECT * FROM t1 WHERE (t1.i) IN
582
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
584
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
585
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
586
id select_type table type possible_keys key key_len ref rows Extra
587
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
588
SELECT * FROM t1 WHERE (t1.i) IN
589
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
591
EXPLAIN SELECT * FROM t1 WHERE (11) IN
592
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
593
id select_type table type possible_keys key key_len ref rows Extra
594
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
595
SELECT * FROM t1 WHERE (11) IN
596
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
598
EXPLAIN SELECT * FROM t1 WHERE (11) IN
599
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
600
id select_type table type possible_keys key key_len ref rows Extra
601
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
602
SELECT * FROM t1 WHERE (11) IN
603
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
605
EXPLAIN SELECT * FROM t1 WHERE (11) IN
606
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
607
id select_type table type possible_keys key key_len ref rows Extra
608
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
609
SELECT * FROM t1 WHERE (11) IN
610
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
612
EXPLAIN SELECT * FROM t1 WHERE (11) IN
613
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
614
id select_type table type possible_keys key key_len ref rows Extra
615
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
616
SELECT * FROM t1 WHERE (11) IN
617
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
619
INSERT INTO t3 VALUES (2);
620
SELECT (SELECT COUNT(*) from t1) AS c1,
621
(SELECT COUNT(*) from t2) AS c2,
622
(SELECT COUNT(*) from t3) AS c3;
625
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
626
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
627
id select_type table type possible_keys key key_len ref rows Extra
628
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
629
SELECT * FROM t1 WHERE (t1.i) IN
630
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
632
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
633
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
638
DEALLOCATE PREPARE stmt;
639
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
640
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
641
id select_type table type possible_keys key key_len ref rows Extra
642
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
643
SELECT * FROM t1 WHERE (t1.i) IN
644
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
646
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
647
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
652
DEALLOCATE PREPARE stmt;
653
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
654
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
655
id select_type table type possible_keys key key_len ref rows Extra
656
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
657
SELECT * FROM t1 WHERE (t1.i) IN
658
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
660
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
661
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
662
id select_type table type possible_keys key key_len ref rows Extra
663
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
664
SELECT * FROM t1 WHERE (t1.i) IN
665
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
667
EXPLAIN SELECT * FROM t1 WHERE (11) IN
668
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
669
id select_type table type possible_keys key key_len ref rows Extra
670
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
671
SELECT * FROM t1 WHERE (11) IN
672
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
674
EXPLAIN SELECT * FROM t1 WHERE (11) IN
675
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
676
id select_type table type possible_keys key key_len ref rows Extra
677
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
678
SELECT * FROM t1 WHERE (11) IN
679
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
681
EXPLAIN SELECT * FROM t1 WHERE (11) IN
682
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
683
id select_type table type possible_keys key key_len ref rows Extra
684
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
685
SELECT * FROM t1 WHERE (11) IN
686
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
688
EXPLAIN SELECT * FROM t1 WHERE (11) IN
689
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
690
id select_type table type possible_keys key key_len ref rows Extra
691
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
692
SELECT * FROM t1 WHERE (11) IN
693
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
695
INSERT INTO t3 VALUES (1);
696
SELECT (SELECT COUNT(*) from t1) AS c1,
697
(SELECT COUNT(*) from t2) AS c2,
698
(SELECT COUNT(*) from t3) AS c3;
701
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
702
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
703
id select_type table type possible_keys key key_len ref rows Extra
704
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
705
SELECT * FROM t1 WHERE (t1.i) IN
706
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
708
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
709
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
714
DEALLOCATE PREPARE stmt;
715
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
716
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
717
id select_type table type possible_keys key key_len ref rows Extra
718
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
719
SELECT * FROM t1 WHERE (t1.i) IN
720
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
722
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
723
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
728
DEALLOCATE PREPARE stmt;
729
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
730
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
731
id select_type table type possible_keys key key_len ref rows Extra
732
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
733
SELECT * FROM t1 WHERE (t1.i) IN
734
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
736
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
737
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
738
id select_type table type possible_keys key key_len ref rows Extra
739
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
740
SELECT * FROM t1 WHERE (t1.i) IN
741
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
743
EXPLAIN SELECT * FROM t1 WHERE (11) IN
744
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
745
id select_type table type possible_keys key key_len ref rows Extra
746
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
747
SELECT * FROM t1 WHERE (11) IN
748
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
750
EXPLAIN SELECT * FROM t1 WHERE (11) IN
751
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
752
id select_type table type possible_keys key key_len ref rows Extra
753
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
754
SELECT * FROM t1 WHERE (11) IN
755
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
757
EXPLAIN SELECT * FROM t1 WHERE (11) IN
758
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
759
id select_type table type possible_keys key key_len ref rows Extra
760
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
761
SELECT * FROM t1 WHERE (11) IN
762
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
764
EXPLAIN SELECT * FROM t1 WHERE (11) IN
765
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
766
id select_type table type possible_keys key key_len ref rows Extra
767
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
768
SELECT * FROM t1 WHERE (11) IN
769
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
771
INSERT INTO t3 VALUES (0);
773
INSERT INTO t2 VALUES (1);
774
SELECT (SELECT COUNT(*) from t1) AS c1,
775
(SELECT COUNT(*) from t2) AS c2,
776
(SELECT COUNT(*) from t3) AS c3;
779
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
780
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
781
id select_type table type possible_keys key key_len ref rows Extra
782
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
783
SELECT * FROM t1 WHERE (t1.i) IN
784
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
786
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
787
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
792
DEALLOCATE PREPARE stmt;
793
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
794
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
795
id select_type table type possible_keys key key_len ref rows Extra
796
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
797
SELECT * FROM t1 WHERE (t1.i) IN
798
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
800
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
801
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
806
DEALLOCATE PREPARE stmt;
807
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
808
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
809
id select_type table type possible_keys key key_len ref rows Extra
810
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
811
SELECT * FROM t1 WHERE (t1.i) IN
812
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
814
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
815
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
816
id select_type table type possible_keys key key_len ref rows Extra
817
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
818
SELECT * FROM t1 WHERE (t1.i) IN
819
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
821
EXPLAIN SELECT * FROM t1 WHERE (11) IN
822
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
823
id select_type table type possible_keys key key_len ref rows Extra
824
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
825
SELECT * FROM t1 WHERE (11) IN
826
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
828
EXPLAIN SELECT * FROM t1 WHERE (11) IN
829
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
830
id select_type table type possible_keys key key_len ref rows Extra
831
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
832
SELECT * FROM t1 WHERE (11) IN
833
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
835
EXPLAIN SELECT * FROM t1 WHERE (11) IN
836
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
837
id select_type table type possible_keys key key_len ref rows Extra
838
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
839
SELECT * FROM t1 WHERE (11) IN
840
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
842
EXPLAIN SELECT * FROM t1 WHERE (11) IN
843
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
844
id select_type table type possible_keys key key_len ref rows Extra
845
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
846
SELECT * FROM t1 WHERE (11) IN
847
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
849
INSERT INTO t3 VALUES (2);
850
SELECT (SELECT COUNT(*) from t1) AS c1,
851
(SELECT COUNT(*) from t2) AS c2,
852
(SELECT COUNT(*) from t3) AS c3;
855
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
856
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
857
id select_type table type possible_keys key key_len ref rows Extra
858
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
859
SELECT * FROM t1 WHERE (t1.i) IN
860
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
862
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
863
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
868
DEALLOCATE PREPARE stmt;
869
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
870
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
871
id select_type table type possible_keys key key_len ref rows Extra
872
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
873
SELECT * FROM t1 WHERE (t1.i) IN
874
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
876
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
877
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
882
DEALLOCATE PREPARE stmt;
883
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
884
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
885
id select_type table type possible_keys key key_len ref rows Extra
886
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
887
SELECT * FROM t1 WHERE (t1.i) IN
888
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
890
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
891
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
892
id select_type table type possible_keys key key_len ref rows Extra
893
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
894
SELECT * FROM t1 WHERE (t1.i) IN
895
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
897
EXPLAIN SELECT * FROM t1 WHERE (11) IN
898
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
899
id select_type table type possible_keys key key_len ref rows Extra
900
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
901
SELECT * FROM t1 WHERE (11) IN
902
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
904
EXPLAIN SELECT * FROM t1 WHERE (11) IN
905
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
906
id select_type table type possible_keys key key_len ref rows Extra
907
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
908
SELECT * FROM t1 WHERE (11) IN
909
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
911
EXPLAIN SELECT * FROM t1 WHERE (11) IN
912
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
913
id select_type table type possible_keys key key_len ref rows Extra
914
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
915
SELECT * FROM t1 WHERE (11) IN
916
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
918
EXPLAIN SELECT * FROM t1 WHERE (11) IN
919
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
920
id select_type table type possible_keys key key_len ref rows Extra
921
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
922
SELECT * FROM t1 WHERE (11) IN
923
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
925
INSERT INTO t3 VALUES (1);
926
SELECT (SELECT COUNT(*) from t1) AS c1,
927
(SELECT COUNT(*) from t2) AS c2,
928
(SELECT COUNT(*) from t3) AS c3;
931
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
932
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
933
id select_type table type possible_keys key key_len ref rows Extra
934
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
935
SELECT * FROM t1 WHERE (t1.i) IN
936
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
938
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
939
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
944
DEALLOCATE PREPARE stmt;
945
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
946
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
947
id select_type table type possible_keys key key_len ref rows Extra
948
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
949
SELECT * FROM t1 WHERE (t1.i) IN
950
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
952
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
953
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
958
DEALLOCATE PREPARE stmt;
959
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
960
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
961
id select_type table type possible_keys key key_len ref rows Extra
962
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
963
SELECT * FROM t1 WHERE (t1.i) IN
964
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
966
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
967
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
968
id select_type table type possible_keys key key_len ref rows Extra
969
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
970
SELECT * FROM t1 WHERE (t1.i) IN
971
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
973
EXPLAIN SELECT * FROM t1 WHERE (11) IN
974
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
975
id select_type table type possible_keys key key_len ref rows Extra
976
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
977
SELECT * FROM t1 WHERE (11) IN
978
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
980
EXPLAIN SELECT * FROM t1 WHERE (11) IN
981
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
982
id select_type table type possible_keys key key_len ref rows Extra
983
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
984
SELECT * FROM t1 WHERE (11) IN
985
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
987
EXPLAIN SELECT * FROM t1 WHERE (11) IN
988
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
989
id select_type table type possible_keys key key_len ref rows Extra
990
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
991
SELECT * FROM t1 WHERE (11) IN
992
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
994
EXPLAIN SELECT * FROM t1 WHERE (11) IN
995
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
996
id select_type table type possible_keys key key_len ref rows Extra
997
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
998
SELECT * FROM t1 WHERE (11) IN
999
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1001
INSERT INTO t3 VALUES (0);
1003
INSERT INTO t2 VALUES (0);
1005
INSERT INTO t1 VALUES (2);
1006
SELECT (SELECT COUNT(*) from t1) AS c1,
1007
(SELECT COUNT(*) from t2) AS c2,
1008
(SELECT COUNT(*) from t3) AS c3;
1011
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1012
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1013
id select_type table type possible_keys key key_len ref rows Extra
1014
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1015
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1016
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1017
SELECT * FROM t1 WHERE (t1.i) IN
1018
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1020
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1021
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1026
DEALLOCATE PREPARE stmt;
1027
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1028
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1029
id select_type table type possible_keys key key_len ref rows Extra
1030
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1031
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1032
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1033
SELECT * FROM t1 WHERE (t1.i) IN
1034
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1036
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1037
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1042
DEALLOCATE PREPARE stmt;
1043
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1044
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1045
id select_type table type possible_keys key key_len ref rows Extra
1046
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1047
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1048
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1049
SELECT * FROM t1 WHERE (t1.i) IN
1050
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1052
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1053
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1054
id select_type table type possible_keys key key_len ref rows Extra
1055
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1056
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1057
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1058
SELECT * FROM t1 WHERE (t1.i) IN
1059
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1061
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1062
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1063
id select_type table type possible_keys key key_len ref rows Extra
1064
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1065
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1066
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1067
SELECT * FROM t1 WHERE (11) IN
1068
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1070
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1071
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1072
id select_type table type possible_keys key key_len ref rows Extra
1073
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1074
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1075
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1076
SELECT * FROM t1 WHERE (11) IN
1077
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1079
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1080
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1081
id select_type table type possible_keys key key_len ref rows Extra
1082
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1083
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1084
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1085
SELECT * FROM t1 WHERE (11) IN
1086
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1088
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1089
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1090
id select_type table type possible_keys key key_len ref rows Extra
1091
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1092
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1093
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1094
SELECT * FROM t1 WHERE (11) IN
1095
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1097
INSERT INTO t3 VALUES (2);
1098
SELECT (SELECT COUNT(*) from t1) AS c1,
1099
(SELECT COUNT(*) from t2) AS c2,
1100
(SELECT COUNT(*) from t3) AS c3;
1103
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1104
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1105
id select_type table type possible_keys key key_len ref rows Extra
1106
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1107
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1108
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1109
SELECT * FROM t1 WHERE (t1.i) IN
1110
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1112
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1113
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1118
DEALLOCATE PREPARE stmt;
1119
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1120
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1121
id select_type table type possible_keys key key_len ref rows Extra
1122
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1123
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1124
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1125
SELECT * FROM t1 WHERE (t1.i) IN
1126
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1128
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1129
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1134
DEALLOCATE PREPARE stmt;
1135
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1136
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1137
id select_type table type possible_keys key key_len ref rows Extra
1138
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1139
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1140
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1141
SELECT * FROM t1 WHERE (t1.i) IN
1142
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1145
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1146
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1147
id select_type table type possible_keys key key_len ref rows Extra
1148
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1149
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1150
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1151
SELECT * FROM t1 WHERE (t1.i) IN
1152
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1154
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1155
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1156
id select_type table type possible_keys key key_len ref rows Extra
1157
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1158
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1159
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1160
SELECT * FROM t1 WHERE (11) IN
1161
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1163
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1164
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1165
id select_type table type possible_keys key key_len ref rows Extra
1166
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1167
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1168
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1169
SELECT * FROM t1 WHERE (11) IN
1170
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1172
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1173
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1174
id select_type table type possible_keys key key_len ref rows Extra
1175
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1176
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1177
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1178
SELECT * FROM t1 WHERE (11) IN
1179
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1181
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1182
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1183
id select_type table type possible_keys key key_len ref rows Extra
1184
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1185
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1186
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1187
SELECT * FROM t1 WHERE (11) IN
1188
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1190
INSERT INTO t3 VALUES (1);
1191
SELECT (SELECT COUNT(*) from t1) AS c1,
1192
(SELECT COUNT(*) from t2) AS c2,
1193
(SELECT COUNT(*) from t3) AS c3;
1196
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1197
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1198
id select_type table type possible_keys key key_len ref rows Extra
1199
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1200
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1201
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1202
SELECT * FROM t1 WHERE (t1.i) IN
1203
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1205
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1206
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1211
DEALLOCATE PREPARE stmt;
1212
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1213
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1214
id select_type table type possible_keys key key_len ref rows Extra
1215
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1216
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1217
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1218
SELECT * FROM t1 WHERE (t1.i) IN
1219
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1221
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1222
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1227
DEALLOCATE PREPARE stmt;
1228
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1229
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1230
id select_type table type possible_keys key key_len ref rows Extra
1231
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1232
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
1233
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
1234
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1235
SELECT * FROM t1 WHERE (t1.i) IN
1236
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1239
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1240
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1241
id select_type table type possible_keys key key_len ref rows Extra
1242
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1243
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1244
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1245
SELECT * FROM t1 WHERE (t1.i) IN
1246
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1248
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1249
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1250
id select_type table type possible_keys key key_len ref rows Extra
1251
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1252
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1253
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1254
SELECT * FROM t1 WHERE (11) IN
1255
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1257
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1258
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1259
id select_type table type possible_keys key key_len ref rows Extra
1260
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1261
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where
1262
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1263
SELECT * FROM t1 WHERE (11) IN
1264
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1266
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1267
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1268
id select_type table type possible_keys key key_len ref rows Extra
1269
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1270
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
1271
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
1272
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1273
SELECT * FROM t1 WHERE (11) IN
1274
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1276
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1277
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1278
id select_type table type possible_keys key key_len ref rows Extra
1279
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1280
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL
1281
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1282
SELECT * FROM t1 WHERE (11) IN
1283
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1285
INSERT INTO t3 VALUES (0);
1287
INSERT INTO t2 VALUES (2);
1288
SELECT (SELECT COUNT(*) from t1) AS c1,
1289
(SELECT COUNT(*) from t2) AS c2,
1290
(SELECT COUNT(*) from t3) AS c3;
1293
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1294
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1295
id select_type table type possible_keys key key_len ref rows Extra
1296
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1297
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1298
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1299
SELECT * FROM t1 WHERE (t1.i) IN
1300
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1302
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1303
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1308
DEALLOCATE PREPARE stmt;
1309
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1310
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1311
id select_type table type possible_keys key key_len ref rows Extra
1312
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1313
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1314
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1315
SELECT * FROM t1 WHERE (t1.i) IN
1316
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1318
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1319
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1324
DEALLOCATE PREPARE stmt;
1325
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1326
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1327
id select_type table type possible_keys key key_len ref rows Extra
1328
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1329
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1330
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1331
SELECT * FROM t1 WHERE (t1.i) IN
1332
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1334
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1335
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1336
id select_type table type possible_keys key key_len ref rows Extra
1337
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1338
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1339
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1340
SELECT * FROM t1 WHERE (t1.i) IN
1341
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1343
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1344
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1345
id select_type table type possible_keys key key_len ref rows Extra
1346
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1347
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1348
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1349
SELECT * FROM t1 WHERE (11) IN
1350
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1352
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1353
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1354
id select_type table type possible_keys key key_len ref rows Extra
1355
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1356
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1357
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1358
SELECT * FROM t1 WHERE (11) IN
1359
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1361
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1362
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1363
id select_type table type possible_keys key key_len ref rows Extra
1364
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1365
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1366
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1367
SELECT * FROM t1 WHERE (11) IN
1368
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1370
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1371
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1372
id select_type table type possible_keys key key_len ref rows Extra
1373
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1374
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1375
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1376
SELECT * FROM t1 WHERE (11) IN
1377
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1379
INSERT INTO t3 VALUES (2);
1380
SELECT (SELECT COUNT(*) from t1) AS c1,
1381
(SELECT COUNT(*) from t2) AS c2,
1382
(SELECT COUNT(*) from t3) AS c3;
1385
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1386
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1387
id select_type table type possible_keys key key_len ref rows Extra
1388
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1389
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1390
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1391
SELECT * FROM t1 WHERE (t1.i) IN
1392
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1395
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1396
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1403
DEALLOCATE PREPARE stmt;
1404
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1405
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1406
id select_type table type possible_keys key key_len ref rows Extra
1407
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1408
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1409
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1410
SELECT * FROM t1 WHERE (t1.i) IN
1411
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1414
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1415
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1422
DEALLOCATE PREPARE stmt;
1423
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1424
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1425
id select_type table type possible_keys key key_len ref rows Extra
1426
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1427
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1428
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1429
SELECT * FROM t1 WHERE (t1.i) IN
1430
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1433
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1434
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1435
id select_type table type possible_keys key key_len ref rows Extra
1436
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1437
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1438
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1439
SELECT * FROM t1 WHERE (t1.i) IN
1440
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1443
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1444
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1445
id select_type table type possible_keys key key_len ref rows Extra
1446
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1447
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1448
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1449
SELECT * FROM t1 WHERE (11) IN
1450
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1452
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1453
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1454
id select_type table type possible_keys key key_len ref rows Extra
1455
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1456
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1457
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1458
SELECT * FROM t1 WHERE (11) IN
1459
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1461
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1462
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1463
id select_type table type possible_keys key key_len ref rows Extra
1464
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1465
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1466
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1467
SELECT * FROM t1 WHERE (11) IN
1468
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1470
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1471
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1472
id select_type table type possible_keys key key_len ref rows Extra
1473
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1474
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1475
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1476
SELECT * FROM t1 WHERE (11) IN
1477
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1479
INSERT INTO t3 VALUES (1);
1480
SELECT (SELECT COUNT(*) from t1) AS c1,
1481
(SELECT COUNT(*) from t2) AS c2,
1482
(SELECT COUNT(*) from t3) AS c3;
1485
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1486
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1487
id select_type table type possible_keys key key_len ref rows Extra
1488
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1489
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1490
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1491
SELECT * FROM t1 WHERE (t1.i) IN
1492
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1495
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1496
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1503
DEALLOCATE PREPARE stmt;
1504
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1505
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1506
id select_type table type possible_keys key key_len ref rows Extra
1507
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1508
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1509
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1510
SELECT * FROM t1 WHERE (t1.i) IN
1511
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1514
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1515
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1522
DEALLOCATE PREPARE stmt;
1523
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1524
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1525
id select_type table type possible_keys key key_len ref rows Extra
1526
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1527
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1528
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1529
SELECT * FROM t1 WHERE (t1.i) IN
1530
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1533
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1534
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1535
id select_type table type possible_keys key key_len ref rows Extra
1536
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1537
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1538
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1539
SELECT * FROM t1 WHERE (t1.i) IN
1540
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1543
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1544
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1545
id select_type table type possible_keys key key_len ref rows Extra
1546
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1547
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1548
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1549
SELECT * FROM t1 WHERE (11) IN
1550
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1552
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1553
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1554
id select_type table type possible_keys key key_len ref rows Extra
1555
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1556
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
1557
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1558
SELECT * FROM t1 WHERE (11) IN
1559
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1561
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1562
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1563
id select_type table type possible_keys key key_len ref rows Extra
1564
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1565
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1566
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1567
SELECT * FROM t1 WHERE (11) IN
1568
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1570
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1571
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1572
id select_type table type possible_keys key key_len ref rows Extra
1573
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1574
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
1575
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1576
SELECT * FROM t1 WHERE (11) IN
1577
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1579
INSERT INTO t3 VALUES (0);
1581
INSERT INTO t2 VALUES (1);
1582
SELECT (SELECT COUNT(*) from t1) AS c1,
1583
(SELECT COUNT(*) from t2) AS c2,
1584
(SELECT COUNT(*) from t3) AS c3;
1587
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1588
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1589
id select_type table type possible_keys key key_len ref rows Extra
1590
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1591
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1592
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1593
SELECT * FROM t1 WHERE (t1.i) IN
1594
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1596
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1597
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1602
DEALLOCATE PREPARE stmt;
1603
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1604
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1605
id select_type table type possible_keys key key_len ref rows Extra
1606
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1607
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1608
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1609
SELECT * FROM t1 WHERE (t1.i) IN
1610
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1612
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1613
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1618
DEALLOCATE PREPARE stmt;
1619
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1620
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1621
id select_type table type possible_keys key key_len ref rows Extra
1622
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1623
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1624
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1625
SELECT * FROM t1 WHERE (t1.i) IN
1626
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1628
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1629
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1630
id select_type table type possible_keys key key_len ref rows Extra
1631
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1632
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
1633
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
1634
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1635
SELECT * FROM t1 WHERE (t1.i) IN
1636
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1638
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1639
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1640
id select_type table type possible_keys key key_len ref rows Extra
1641
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1642
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1643
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1644
SELECT * FROM t1 WHERE (11) IN
1645
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1647
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1648
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1649
id select_type table type possible_keys key key_len ref rows Extra
1650
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1651
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1652
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1653
SELECT * FROM t1 WHERE (11) IN
1654
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1656
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1657
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1658
id select_type table type possible_keys key key_len ref rows Extra
1659
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1660
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where
1661
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1662
SELECT * FROM t1 WHERE (11) IN
1663
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1665
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1666
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1667
id select_type table type possible_keys key key_len ref rows Extra
1668
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1669
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
1670
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
1671
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1672
SELECT * FROM t1 WHERE (11) IN
1673
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1675
INSERT INTO t3 VALUES (2);
1676
SELECT (SELECT COUNT(*) from t1) AS c1,
1677
(SELECT COUNT(*) from t2) AS c2,
1678
(SELECT COUNT(*) from t3) AS c3;
1681
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1682
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1683
id select_type table type possible_keys key key_len ref rows Extra
1684
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1685
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1686
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1687
SELECT * FROM t1 WHERE (t1.i) IN
1688
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1691
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1692
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1699
DEALLOCATE PREPARE stmt;
1700
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1701
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1702
id select_type table type possible_keys key key_len ref rows Extra
1703
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1704
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1705
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1706
SELECT * FROM t1 WHERE (t1.i) IN
1707
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1710
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1711
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1718
DEALLOCATE PREPARE stmt;
1719
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1720
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1721
id select_type table type possible_keys key key_len ref rows Extra
1722
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1723
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1724
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1725
SELECT * FROM t1 WHERE (t1.i) IN
1726
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1729
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1730
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1731
id select_type table type possible_keys key key_len ref rows Extra
1732
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1733
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
1734
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1735
SELECT * FROM t1 WHERE (t1.i) IN
1736
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1739
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1740
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1741
id select_type table type possible_keys key key_len ref rows Extra
1742
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1743
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1744
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1745
SELECT * FROM t1 WHERE (11) IN
1746
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1748
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1749
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1750
id select_type table type possible_keys key key_len ref rows Extra
1751
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1752
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1753
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1754
SELECT * FROM t1 WHERE (11) IN
1755
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1757
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1758
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1759
id select_type table type possible_keys key key_len ref rows Extra
1760
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1761
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
1762
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1763
SELECT * FROM t1 WHERE (11) IN
1764
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1766
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1767
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1768
id select_type table type possible_keys key key_len ref rows Extra
1769
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1770
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
1771
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
1772
SELECT * FROM t1 WHERE (11) IN
1773
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1775
INSERT INTO t3 VALUES (1);
1776
SELECT (SELECT COUNT(*) from t1) AS c1,
1777
(SELECT COUNT(*) from t2) AS c2,
1778
(SELECT COUNT(*) from t3) AS c3;
1781
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1782
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1783
id select_type table type possible_keys key key_len ref rows Extra
1784
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1785
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
1786
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1787
SELECT * FROM t1 WHERE (t1.i) IN
1788
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1791
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1792
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1799
DEALLOCATE PREPARE stmt;
1800
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1801
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1802
id select_type table type possible_keys key key_len ref rows Extra
1803
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1804
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
1805
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1806
SELECT * FROM t1 WHERE (t1.i) IN
1807
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1810
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1811
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1818
DEALLOCATE PREPARE stmt;
1819
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1820
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1821
id select_type table type possible_keys key key_len ref rows Extra
1822
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1823
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1824
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1825
SELECT * FROM t1 WHERE (t1.i) IN
1826
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1829
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1830
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1831
id select_type table type possible_keys key key_len ref rows Extra
1832
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1833
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
1834
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1835
SELECT * FROM t1 WHERE (t1.i) IN
1836
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1839
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1840
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1841
id select_type table type possible_keys key key_len ref rows Extra
1842
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1843
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
1844
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1845
SELECT * FROM t1 WHERE (11) IN
1846
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1848
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1849
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1850
id select_type table type possible_keys key key_len ref rows Extra
1851
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1852
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
1853
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1854
SELECT * FROM t1 WHERE (11) IN
1855
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1857
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1858
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1859
id select_type table type possible_keys key key_len ref rows Extra
1860
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1861
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1862
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1863
SELECT * FROM t1 WHERE (11) IN
1864
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1866
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1867
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1868
id select_type table type possible_keys key key_len ref rows Extra
1869
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL
1870
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
1871
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
1872
SELECT * FROM t1 WHERE (11) IN
1873
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1875
INSERT INTO t3 VALUES (0);
1877
INSERT INTO t2 VALUES (0);
1879
INSERT INTO t1 VALUES (1);
1880
SELECT (SELECT COUNT(*) from t1) AS c1,
1881
(SELECT COUNT(*) from t2) AS c2,
1882
(SELECT COUNT(*) from t3) AS c3;
1885
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1886
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1887
id select_type table type possible_keys key key_len ref rows Extra
1888
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
1889
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
1890
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
1891
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1892
SELECT * FROM t1 WHERE (t1.i) IN
1893
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1895
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1896
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1901
DEALLOCATE PREPARE stmt;
1902
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1903
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1904
id select_type table type possible_keys key key_len ref rows Extra
1905
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
1906
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
1907
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
1908
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1909
SELECT * FROM t1 WHERE (t1.i) IN
1910
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1912
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1913
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
1918
DEALLOCATE PREPARE stmt;
1919
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1920
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1921
id select_type table type possible_keys key key_len ref rows Extra
1922
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
1923
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
1924
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL
1925
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1926
SELECT * FROM t1 WHERE (t1.i) IN
1927
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1929
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1930
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1931
id select_type table type possible_keys key key_len ref rows Extra
1932
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
1933
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
1934
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
1935
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop)
1936
SELECT * FROM t1 WHERE (t1.i) IN
1937
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1939
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1940
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1941
id select_type table type possible_keys key key_len ref rows Extra
1942
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
1943
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
1944
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1945
SELECT * FROM t1 WHERE (11) IN
1946
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
1948
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1949
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1950
id select_type table type possible_keys key key_len ref rows Extra
1951
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary
1952
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
1953
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
1954
SELECT * FROM t1 WHERE (11) IN
1955
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
1957
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1958
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1959
id select_type table type possible_keys key key_len ref rows Extra
1960
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
1961
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
1962
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1963
SELECT * FROM t1 WHERE (11) IN
1964
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
1966
EXPLAIN SELECT * FROM t1 WHERE (11) IN
1967
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1968
id select_type table type possible_keys key key_len ref rows Extra
1969
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch
1970
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
1971
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1)
1972
SELECT * FROM t1 WHERE (11) IN
1973
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
1975
INSERT INTO t3 VALUES (2);
1976
SELECT (SELECT COUNT(*) from t1) AS c1,
1977
(SELECT COUNT(*) from t2) AS c2,
1978
(SELECT COUNT(*) from t3) AS c3;
1981
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1982
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1983
id select_type table type possible_keys key key_len ref rows Extra
1984
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
1985
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
1986
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
1987
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
1988
SELECT * FROM t1 WHERE (t1.i) IN
1989
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
1991
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
1992
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
1997
DEALLOCATE PREPARE stmt;
1998
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
1999
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2000
id select_type table type possible_keys key key_len ref rows Extra
2001
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2002
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2003
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
2004
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2005
SELECT * FROM t1 WHERE (t1.i) IN
2006
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2008
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2009
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2014
DEALLOCATE PREPARE stmt;
2015
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2016
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2017
id select_type table type possible_keys key key_len ref rows Extra
2018
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2019
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2020
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 NULL
2021
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
2022
SELECT * FROM t1 WHERE (t1.i) IN
2023
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2026
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2027
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2028
id select_type table type possible_keys key key_len ref rows Extra
2029
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2030
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2031
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL
2032
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop)
2033
SELECT * FROM t1 WHERE (t1.i) IN
2034
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2036
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2037
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2038
id select_type table type possible_keys key key_len ref rows Extra
2039
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2040
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2041
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
2042
SELECT * FROM t1 WHERE (11) IN
2043
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2045
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2046
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2047
id select_type table type possible_keys key key_len ref rows Extra
2048
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary
2049
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2050
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2051
SELECT * FROM t1 WHERE (11) IN
2052
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2054
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2055
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2056
id select_type table type possible_keys key key_len ref rows Extra
2057
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
2058
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2059
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2060
SELECT * FROM t1 WHERE (11) IN
2061
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2063
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2064
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2065
id select_type table type possible_keys key key_len ref rows Extra
2066
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch
2067
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2068
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
2069
SELECT * FROM t1 WHERE (11) IN
2070
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2072
INSERT INTO t3 VALUES (1);
2073
SELECT (SELECT COUNT(*) from t1) AS c1,
2074
(SELECT COUNT(*) from t2) AS c2,
2075
(SELECT COUNT(*) from t3) AS c3;
2078
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2079
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2080
id select_type table type possible_keys key key_len ref rows Extra
2081
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary
2082
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2083
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2084
SELECT * FROM t1 WHERE (t1.i) IN
2085
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2087
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2088
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2093
DEALLOCATE PREPARE stmt;
2094
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2095
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2096
id select_type table type possible_keys key key_len ref rows Extra
2097
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary
2098
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2099
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2100
SELECT * FROM t1 WHERE (t1.i) IN
2101
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2103
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2104
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2109
DEALLOCATE PREPARE stmt;
2110
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2111
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2112
id select_type table type possible_keys key key_len ref rows Extra
2113
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2114
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2115
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL
2116
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
2117
SELECT * FROM t1 WHERE (t1.i) IN
2118
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2122
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2123
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2124
id select_type table type possible_keys key key_len ref rows Extra
2125
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary
2126
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2127
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2128
SELECT * FROM t1 WHERE (t1.i) IN
2129
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2131
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2132
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2133
id select_type table type possible_keys key key_len ref rows Extra
2134
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2135
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2136
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
2137
SELECT * FROM t1 WHERE (11) IN
2138
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2140
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2141
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2142
id select_type table type possible_keys key key_len ref rows Extra
2143
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary
2144
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2145
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2146
SELECT * FROM t1 WHERE (11) IN
2147
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2149
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2150
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2151
id select_type table type possible_keys key key_len ref rows Extra
2152
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
2153
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2154
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
2155
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
2156
SELECT * FROM t1 WHERE (11) IN
2157
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2159
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2160
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2161
id select_type table type possible_keys key key_len ref rows Extra
2162
1 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch
2163
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2164
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
2165
SELECT * FROM t1 WHERE (11) IN
2166
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2168
INSERT INTO t3 VALUES (0);
2170
INSERT INTO t2 VALUES (2);
2171
SELECT (SELECT COUNT(*) from t1) AS c1,
2172
(SELECT COUNT(*) from t2) AS c2,
2173
(SELECT COUNT(*) from t3) AS c3;
2176
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2177
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2178
id select_type table type possible_keys key key_len ref rows Extra
2179
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2180
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2181
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL
2182
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2183
SELECT * FROM t1 WHERE (t1.i) IN
2184
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2186
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2187
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2192
DEALLOCATE PREPARE stmt;
2193
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2194
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2195
id select_type table type possible_keys key key_len ref rows Extra
2196
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2197
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2198
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL
2199
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2200
SELECT * FROM t1 WHERE (t1.i) IN
2201
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2203
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2204
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2209
DEALLOCATE PREPARE stmt;
2210
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2211
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2212
id select_type table type possible_keys key key_len ref rows Extra
2213
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2214
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2215
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL
2216
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2217
SELECT * FROM t1 WHERE (t1.i) IN
2218
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2220
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2221
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2222
id select_type table type possible_keys key key_len ref rows Extra
2223
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2224
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2225
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL
2226
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop)
2227
SELECT * FROM t1 WHERE (t1.i) IN
2228
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2230
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2231
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2232
id select_type table type possible_keys key key_len ref rows Extra
2233
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2234
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2235
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
2236
SELECT * FROM t1 WHERE (11) IN
2237
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2239
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2240
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2241
id select_type table type possible_keys key key_len ref rows Extra
2242
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Start temporary
2243
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2244
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2245
SELECT * FROM t1 WHERE (11) IN
2246
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2248
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2249
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2250
id select_type table type possible_keys key key_len ref rows Extra
2251
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2252
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2253
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1)
2254
SELECT * FROM t1 WHERE (11) IN
2255
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2257
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2258
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2259
id select_type table type possible_keys key key_len ref rows Extra
2260
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
2261
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2262
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2263
SELECT * FROM t1 WHERE (11) IN
2264
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2266
INSERT INTO t3 VALUES (2);
2267
SELECT (SELECT COUNT(*) from t1) AS c1,
2268
(SELECT COUNT(*) from t2) AS c2,
2269
(SELECT COUNT(*) from t3) AS c3;
2272
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2273
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2274
id select_type table type possible_keys key key_len ref rows Extra
2275
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2276
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2277
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL
2278
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2279
SELECT * FROM t1 WHERE (t1.i) IN
2280
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2283
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2284
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2291
DEALLOCATE PREPARE stmt;
2292
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2293
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2294
id select_type table type possible_keys key key_len ref rows Extra
2295
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2296
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2297
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL
2298
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2299
SELECT * FROM t1 WHERE (t1.i) IN
2300
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2303
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2304
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2311
DEALLOCATE PREPARE stmt;
2312
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2313
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2314
id select_type table type possible_keys key key_len ref rows Extra
2315
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2316
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2317
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 NULL
2318
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2319
SELECT * FROM t1 WHERE (t1.i) IN
2320
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2323
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2324
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2325
id select_type table type possible_keys key key_len ref rows Extra
2326
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2327
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2328
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL
2329
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop)
2330
SELECT * FROM t1 WHERE (t1.i) IN
2331
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2334
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2335
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2336
id select_type table type possible_keys key key_len ref rows Extra
2337
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
2338
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch
2339
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2340
SELECT * FROM t1 WHERE (11) IN
2341
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2343
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2344
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2345
id select_type table type possible_keys key key_len ref rows Extra
2346
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary
2347
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2348
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2349
SELECT * FROM t1 WHERE (11) IN
2350
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2352
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2353
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2354
id select_type table type possible_keys key key_len ref rows Extra
2355
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
2356
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch
2357
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2358
SELECT * FROM t1 WHERE (11) IN
2359
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2361
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2362
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2363
id select_type table type possible_keys key key_len ref rows Extra
2364
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
2365
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch
2366
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2367
SELECT * FROM t1 WHERE (11) IN
2368
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2370
INSERT INTO t3 VALUES (1);
2371
SELECT (SELECT COUNT(*) from t1) AS c1,
2372
(SELECT COUNT(*) from t2) AS c2,
2373
(SELECT COUNT(*) from t3) AS c3;
2376
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2377
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2378
id select_type table type possible_keys key key_len ref rows Extra
2379
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary
2380
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2381
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2382
SELECT * FROM t1 WHERE (t1.i) IN
2383
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2386
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2387
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2394
DEALLOCATE PREPARE stmt;
2395
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2396
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2397
id select_type table type possible_keys key key_len ref rows Extra
2398
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary
2399
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2400
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2401
SELECT * FROM t1 WHERE (t1.i) IN
2402
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2405
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2406
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2413
DEALLOCATE PREPARE stmt;
2414
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2415
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2416
id select_type table type possible_keys key key_len ref rows Extra
2417
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2418
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2419
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL
2420
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
2421
SELECT * FROM t1 WHERE (t1.i) IN
2422
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2426
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2427
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2428
id select_type table type possible_keys key key_len ref rows Extra
2429
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary
2430
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2431
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2432
SELECT * FROM t1 WHERE (t1.i) IN
2433
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2437
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2438
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2439
id select_type table type possible_keys key key_len ref rows Extra
2440
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
2441
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch
2442
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2443
SELECT * FROM t1 WHERE (11) IN
2444
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2446
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2447
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2448
id select_type table type possible_keys key key_len ref rows Extra
2449
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary
2450
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2451
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2452
SELECT * FROM t1 WHERE (11) IN
2453
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2455
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2456
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2457
id select_type table type possible_keys key key_len ref rows Extra
2458
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
2459
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch
2460
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2461
SELECT * FROM t1 WHERE (11) IN
2462
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2464
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2465
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2466
id select_type table type possible_keys key key_len ref rows Extra
2467
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL
2468
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch
2469
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2470
SELECT * FROM t1 WHERE (11) IN
2471
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2473
INSERT INTO t3 VALUES (0);
2475
INSERT INTO t2 VALUES (1);
2476
SELECT (SELECT COUNT(*) from t1) AS c1,
2477
(SELECT COUNT(*) from t2) AS c2,
2478
(SELECT COUNT(*) from t3) AS c3;
2481
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2482
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2483
id select_type table type possible_keys key key_len ref rows Extra
2484
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary
2485
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2486
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2487
SELECT * FROM t1 WHERE (t1.i) IN
2488
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2490
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2491
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2496
DEALLOCATE PREPARE stmt;
2497
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2498
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2499
id select_type table type possible_keys key key_len ref rows Extra
2500
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary
2501
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2502
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2503
SELECT * FROM t1 WHERE (t1.i) IN
2504
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2506
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2507
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2512
DEALLOCATE PREPARE stmt;
2513
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2514
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2515
id select_type table type possible_keys key key_len ref rows Extra
2516
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary
2517
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2518
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2519
SELECT * FROM t1 WHERE (t1.i) IN
2520
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2522
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2523
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2524
id select_type table type possible_keys key key_len ref rows Extra
2525
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2526
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2527
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2528
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop)
2529
SELECT * FROM t1 WHERE (t1.i) IN
2530
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2532
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2533
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2534
id select_type table type possible_keys key key_len ref rows Extra
2535
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2536
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2537
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
2538
SELECT * FROM t1 WHERE (11) IN
2539
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2541
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2542
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2543
id select_type table type possible_keys key key_len ref rows Extra
2544
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Start temporary
2545
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2546
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2547
SELECT * FROM t1 WHERE (11) IN
2548
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2550
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2551
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2552
id select_type table type possible_keys key key_len ref rows Extra
2553
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch
2554
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2555
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
2556
SELECT * FROM t1 WHERE (11) IN
2557
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2559
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2560
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2561
id select_type table type possible_keys key key_len ref rows Extra
2562
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
2563
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2564
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2565
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop)
2566
SELECT * FROM t1 WHERE (11) IN
2567
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2569
INSERT INTO t3 VALUES (2);
2570
SELECT (SELECT COUNT(*) from t1) AS c1,
2571
(SELECT COUNT(*) from t2) AS c2,
2572
(SELECT COUNT(*) from t3) AS c3;
2575
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2576
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2577
id select_type table type possible_keys key key_len ref rows Extra
2578
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary
2579
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2580
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2581
SELECT * FROM t1 WHERE (t1.i) IN
2582
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2585
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2586
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2593
DEALLOCATE PREPARE stmt;
2594
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2595
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2596
id select_type table type possible_keys key key_len ref rows Extra
2597
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary
2598
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2599
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2600
SELECT * FROM t1 WHERE (t1.i) IN
2601
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2604
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2605
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2612
DEALLOCATE PREPARE stmt;
2613
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2614
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2615
id select_type table type possible_keys key key_len ref rows Extra
2616
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary
2617
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2618
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2619
SELECT * FROM t1 WHERE (t1.i) IN
2620
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2623
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2624
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2625
id select_type table type possible_keys key key_len ref rows Extra
2626
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
2627
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2628
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2629
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop)
2630
SELECT * FROM t1 WHERE (t1.i) IN
2631
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2634
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2635
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2636
id select_type table type possible_keys key key_len ref rows Extra
2637
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
2638
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch
2639
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2640
SELECT * FROM t1 WHERE (11) IN
2641
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2643
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2644
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2645
id select_type table type possible_keys key key_len ref rows Extra
2646
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Start temporary
2647
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2648
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2649
SELECT * FROM t1 WHERE (11) IN
2650
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2652
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2653
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2654
id select_type table type possible_keys key key_len ref rows Extra
2655
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
2656
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch
2657
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2658
SELECT * FROM t1 WHERE (11) IN
2659
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2661
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2662
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2663
id select_type table type possible_keys key key_len ref rows Extra
2664
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
2665
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch
2666
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2667
SELECT * FROM t1 WHERE (11) IN
2668
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2670
INSERT INTO t3 VALUES (1);
2671
SELECT (SELECT COUNT(*) from t1) AS c1,
2672
(SELECT COUNT(*) from t2) AS c2,
2673
(SELECT COUNT(*) from t3) AS c3;
2676
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2677
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2678
id select_type table type possible_keys key key_len ref rows Extra
2679
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2680
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL
2681
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2682
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2683
SELECT * FROM t1 WHERE (t1.i) IN
2684
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i);
2688
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2689
(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)";
2698
DEALLOCATE PREPARE stmt;
2699
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2700
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2701
id select_type table type possible_keys key key_len ref rows Extra
2702
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2703
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL
2704
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2705
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2706
SELECT * FROM t1 WHERE (t1.i) IN
2707
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2711
PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN
2712
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)";
2721
DEALLOCATE PREPARE stmt;
2722
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2723
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2724
id select_type table type possible_keys key key_len ref rows Extra
2725
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2726
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL
2727
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL
2728
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2729
SELECT * FROM t1 WHERE (t1.i) IN
2730
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2734
EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
2735
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2736
id select_type table type possible_keys key key_len ref rows Extra
2737
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2738
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL
2739
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2740
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
2741
SELECT * FROM t1 WHERE (t1.i) IN
2742
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2746
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2747
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2748
id select_type table type possible_keys key key_len ref rows Extra
2749
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2750
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
2751
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
2752
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2753
SELECT * FROM t1 WHERE (11) IN
2754
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
2756
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2757
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2758
id select_type table type possible_keys key key_len ref rows Extra
2759
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Start temporary
2760
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2761
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
2762
SELECT * FROM t1 WHERE (11) IN
2763
(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
2765
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2766
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2767
id select_type table type possible_keys key key_len ref rows Extra
2768
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2769
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
2770
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
2771
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2772
SELECT * FROM t1 WHERE (11) IN
2773
(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
2775
EXPLAIN SELECT * FROM t1 WHERE (11) IN
2776
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2777
id select_type table type possible_keys key key_len ref rows Extra
2778
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
2779
1 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL
2780
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
2781
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
2782
SELECT * FROM t1 WHERE (11) IN
2783
(SELECT t3.i FROM t2 STRAIGHT_JOIN t3);
2785
INSERT INTO t3 VALUES (0);
2787
INSERT INTO t2 VALUES (0);
2789
INSERT INTO t1 VALUES (0);
2790
DROP TABLE t1, t2, t3;
2791
create table x1(k int primary key, d1 int, d2 int);
2792
create table x2(k int primary key, d1 int, d2 int);
2793
insert into x1 values
2799
insert into x2 values
2806
where (d1, d2) in (select d1, d2
2813
where (d1, d2) in (select d1, d2
2820
where (d1, d2) in (select d1, d2
2826
where (d1, d2) in (select d1, d2
2827
from x2) is unknown;
2833
where d1 in (select d1
2841
where d1 in (select d1
2843
where x1.d2=x2.d2) is true;
2849
where d1 in (select d1
2851
where x1.d2=x2.d2) is false;
2857
where d1 in (select d1
2859
where x1.d2=x2.d2) is unknown;
2864
where 1 in (select 1
2866
where x1.d1=x2.d1 and x1.d2=x2.d2);
2872
where 1 in (select 1
2874
where x1.d1=x2.d1 and x1.d2=x2.d2) is true;
2880
where 1 in (select 1
2882
where x1.d1=x2.d1 and x1.d2=x2.d2) is false;
2889
where 1 in (select 1
2891
where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown;
2895
where exists (select *
2897
where x1.d1=x2.d1 and x1.d2=x2.d2);
2906
c datetime default NULL,
2910
INSERT INTO t1 VALUES
2911
(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'),
2912
(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'),
2913
(406994,67,'2006-02-27 11:26:46'), (256,67,NULL),
2914
(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL),
2915
(406988,67,'2006-02-23 17:07:22'), (255,67,NULL),
2916
(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'),
2917
(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'),
2918
(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'),
2919
(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'),
2920
(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'),
2921
(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'),
2922
(223456,67,NULL),(4101,67,NULL),(1133,67,NULL),
2923
(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'),
2924
(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'),
2925
(154503,67,'2005-10-28 11:52:38');
2926
create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc;
2927
create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc;
2928
create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc;
2929
create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc;
2930
update t22 set c = '2005-12-08 15:58:27' where a = 255;
2931
explain select t21.* from t21,t22 where t21.a = t22.a and
2932
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;
2933
id select_type table type possible_keys key key_len ref rows Extra
2934
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using temporary; Using filesort
2935
1 SIMPLE t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (Block Nested Loop)
2936
1 SIMPLE t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (Block Nested Loop)
2937
2 MATERIALIZED t11 ALL NULL NULL NULL NULL 8 Using where
2938
2 MATERIALIZED t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
2939
explain format=json select * from t1 where a in (select a from t11);
2944
"duplicates_removal": {
2945
"using_temporary_table": true,
2949
"table_name": "t11",
2950
"access_type": "ALL",
2958
"access_type": "eq_ref",
2972
"using_join_buffer": "Batched Key Access (unique)"
2980
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`)
2981
select t21.* from t21,t22 where t21.a = t22.a and
2982
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;
2985
drop table t1, t11, t12, t21, t22;
2986
create table t1(a int);
2987
insert into t1 values (0),(1);
2989
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;
2990
id select_type table type possible_keys key key_len ref rows Extra
2991
1 PRIMARY X ALL NULL NULL NULL NULL 2 NULL
2992
2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
2993
2 DEPENDENT SUBQUERY Z ALL NULL NULL NULL NULL 2 Using where; FirstMatch(Y); Using join buffer (Block Nested Loop)
2994
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;
2999
create table t0 (a int);
3000
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3001
create table t1 as select * from t0;
3002
insert into t1 select a+10 from t0;
3003
insert into t0 values(2);
3004
explain select * from t1 where 2 in (select a from t0);
3005
id select_type table type possible_keys key key_len ref rows Extra
3006
1 SIMPLE t0 ALL NULL NULL NULL NULL 11 Using where; FirstMatch
3007
1 SIMPLE t1 ALL NULL NULL NULL NULL 20 Using join buffer (Block Nested Loop)
3008
select * from t1 where 2 in (select a from t0);
3030
explain select * from (select a from t0) x where a in (select a from t1);
3031
id select_type table type possible_keys key key_len ref rows Extra
3032
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 Using where
3033
1 PRIMARY <subquery3> eq_ref <auto_key> <auto_key> 5 x.a 1 NULL
3034
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 20 NULL
3035
2 DERIVED t0 ALL NULL NULL NULL NULL 11 NULL
3036
explain format=json select * from (select a from t0) x where a in (select a from t1);
3045
"access_type": "ALL",
3048
"attached_condition": "(`x`.`a` is not null)",
3049
"materialized_from_subquery": {
3050
"using_temporary_table": true,
3057
"access_type": "ALL",
3067
"table_name": "<subquery3>",
3068
"access_type": "eq_ref",
3069
"key": "<auto_key>",
3075
"materialized_from_subquery": {
3076
"using_temporary_table": true,
3080
"access_type": "ALL",
3092
Note 1003 /* select#1 */ select `x`.`a` AS `a` from (/* select#2 */ select `test`.`t0`.`a` AS `a` from `test`.`t0`) `x` semi join (`test`.`t1`) where (`<subquery3>`.`a` = `x`.`a`)
3094
create table t0 (a int);
3095
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3096
create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2));
3097
insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C;
3098
insert into t1 select * from t1 where kp1 < 20;
3099
create table t3 (a int);
3100
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
3101
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
3102
id select_type table type possible_keys key key_len ref rows Extra
3103
1 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where
3104
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL
3105
2 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using where; Using index
3106
select * from t3 where a in (select kp1 from t1 where kp1<20);
3128
explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20;
3129
id select_type table type possible_keys key key_len ref rows Extra
3130
1 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where
3131
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL
3132
2 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using where; Using index
3133
select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20;
3155
create table t4 (pk int primary key);
3156
insert into t4 select a from t3;
3157
explain select * from t3 where a in
3158
(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
3159
id select_type table type possible_keys key key_len ref rows Extra
3160
1 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where
3161
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL
3162
2 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Using MRR
3163
2 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index
3164
select * from t3 where a in
3165
(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
3187
drop table t1, t3, t4;
3188
create table t1 (a int);
3189
insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3);
3190
set @save_max_heap_table_size=@@max_heap_table_size;
3191
set @@max_heap_table_size= 16384;
3192
# Attempt to make one test that overflows the heap table when a
3193
# non-duplicate row is inserted and one test that overflows the
3194
# heap table when a duplicate record is inserted. Debugging showed
3195
# that these situations occurred with max_heap_table_size=16384
3196
# and optimizer_join_cache_level equals 1 and 0, respectively.
3197
# Finally execute a test that does not overflow the heap table.
3199
select count(*) from t0 A, t0 B, t0 C
3200
where C.a in (select a from t1 D);
3201
id select_type table type possible_keys key key_len ref rows Extra
3202
1 SIMPLE A ALL NULL NULL NULL NULL 10 NULL
3203
1 SIMPLE B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3204
1 SIMPLE C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop)
3205
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.C.a 1 NULL
3206
2 MATERIALIZED D ALL NULL NULL NULL NULL 12 NULL
3208
select count(*) from t0 A, t0 B, t0 C
3209
where C.a in (select a from t1 D);
3212
show status like 'Created_tmp_disk_tables';
3214
Created_tmp_disk_tables 0
3215
set @@max_heap_table_size= @save_max_heap_table_size;
3217
select count(*) from t0 A, t0 B, t0 C
3218
where C.a in (select a from t1 D);
3221
show status like 'Created_tmp_disk_tables';
3223
Created_tmp_disk_tables 0
3225
create table t0 (a int);
3226
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3227
create table t2(a int);
3228
insert into t2 values (1),(2);
3229
create table t3 ( a int , filler char(100), key(a));
3230
insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B;
3231
explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10);
3232
id select_type table type possible_keys key key_len ref rows Extra
3233
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
3234
1 SIMPLE t3 ref a a 5 test.t2.a 1 End temporary; Using join buffer (Batched Key Access (unique))
3235
select * from t3 where a in (select a from t2);
3239
drop table t0, t2, t3;
3240
create table t1 (a date);
3241
insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01');
3242
create table t2 (a int);
3243
insert into t2 values (1),(2);
3244
create table t3 (a char(10));
3245
insert into t3 select * from t1;
3246
insert into t3 values (1),(2);
3247
explain select * from t2 where a in (select a from t1);
3248
id select_type table type possible_keys key key_len ref rows Extra
3249
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
3250
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop)
3251
explain select * from t2 where a in (select a from t2);
3252
id select_type table type possible_keys key key_len ref rows Extra
3253
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
3254
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop)
3255
explain select * from t2 where a in (select a from t3);
3256
id select_type table type possible_keys key key_len ref rows Extra
3257
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL
3258
1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop)
3259
explain select * from t1 where a in (select a from t3);
3260
id select_type table type possible_keys key key_len ref rows Extra
3261
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 NULL
3262
1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop)
3263
drop table t1, t2, t3;
3264
create table t1 (a decimal);
3265
insert into t1 values (1),(2);
3266
explain select * from t1 where a in (select a from t1);
3267
id select_type table type possible_keys key key_len ref rows Extra
3268
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
3269
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop)
3271
create table t1 (a int);
3272
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3273
create table t2 as select * from t1;
3274
create table t3 (a int, b int, filler char(100), key(a));
3275
insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C;
3276
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;
3277
id select_type table type possible_keys key key_len ref rows Extra
3278
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
3279
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where; Using join buffer (Block Nested Loop)
3280
1 SIMPLE t3 ref a a 5 <subquery2>.a 10 Using join buffer (Batched Key Access (unique))
3281
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL
3282
explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3;
3291
"access_type": "ALL",
3294
"attached_condition": "(`test`.`t1`.`a` = 3)"
3299
"table_name": "<subquery2>",
3300
"access_type": "ALL",
3301
"attached_condition": "(((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30)) and (`<subquery2>`.`a` is not null))",
3302
"materialized_from_subquery": {
3303
"using_temporary_table": true,
3307
"access_type": "ALL",
3318
"access_type": "ref",
3332
"using_join_buffer": "Batched Key Access (unique)"
3339
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` semi join (`test`.`t2`) join `test`.`t3` where ((`test`.`t3`.`a` = `<subquery2>`.`a`) and (`test`.`t1`.`a` = 3) and ((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30)))
3340
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2);
3341
id select_type table type possible_keys key key_len ref rows Extra
3342
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
3343
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3344
2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL
3345
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
3346
id select_type table type possible_keys key key_len ref rows Extra
3347
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
3348
2 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL
3349
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3350
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
3351
id select_type table type possible_keys key key_len ref rows Extra
3352
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
3353
2 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL
3354
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3355
explain select straight_join * from t2 X, t2 Y
3356
where X.a in (select straight_join A.a from t1 A, t1 B);
3357
id select_type table type possible_keys key key_len ref rows Extra
3358
1 PRIMARY X ALL NULL NULL NULL NULL 10 Using where
3359
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3360
2 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL
3361
2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop)
3362
create table t0 (a int, b int);
3363
insert into t0 values(1,1);
3364
explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30);
3365
id select_type table type possible_keys key key_len ref rows Extra
3366
1 SIMPLE t0 system NULL NULL NULL NULL 1 NULL
3367
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where
3368
1 SIMPLE t3 ref a a 5 <subquery2>.a 10 Using join buffer (Batched Key Access (unique))
3369
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL
3370
create table t4 as select a as x, a as y from t1;
3371
explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30);
3372
id select_type table type possible_keys key key_len ref rows Extra
3373
1 SIMPLE t0 system NULL NULL NULL NULL 1 NULL
3374
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where
3375
1 SIMPLE t3 ref a a 5 <subquery2>.x 10 Using where; Using join buffer (Batched Key Access (unique))
3376
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 10 NULL
3377
drop table t0,t1,t2,t3,t4;
3378
create table t0 (a int);
3379
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3380
create table t1 (a int, b int, filler char(100), key(a,b));
3381
insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
3382
create table t2 as select * from t1;
3383
explain select * from t2 where a in (select b from t1 where a=3);
3384
id select_type table type possible_keys key key_len ref rows Extra
3385
1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where
3386
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t2.a 1 NULL
3387
2 MATERIALIZED t1 ref a a 5 const 8 Using index
3388
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
3389
id select_type table type possible_keys key key_len ref rows Extra
3390
1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where
3391
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t2.b,test.t2.a 1 Using where
3392
2 MATERIALIZED t1 ref a a 5 const 8 Using index
3394
create table t1 (a int, b int);
3395
insert into t1 select a,a from t0;
3396
create table t2 (a int, b int);
3397
insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B;
3398
explain select * from t1 where (a,b) in (select a,b from t2);
3399
id select_type table type possible_keys key key_len ref rows Extra
3400
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
3401
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t1.a,test.t1.b 1 NULL
3402
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 100 NULL
3403
drop table t0, t1, t2;
3404
create table t0 (a decimal(4,2));
3405
insert into t0 values (10.24), (22.11);
3406
create table t1 as select * from t0;
3407
insert into t1 select * from t0;
3408
explain select * from t0 where a in (select a from t1);
3409
id select_type table type possible_keys key key_len ref rows Extra
3410
1 SIMPLE t0 ALL NULL NULL NULL NULL 2 NULL
3411
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop)
3412
select * from t0 where a in (select a from t1);
3417
create table t0(a date);
3418
insert into t0 values ('2008-01-01'),('2008-02-02');
3419
create table t1 as select * from t0;
3420
insert into t1 select * from t0;
3421
explain select * from t0 where a in (select a from t1);
3422
id select_type table type possible_keys key key_len ref rows Extra
3423
1 SIMPLE t0 ALL NULL NULL NULL NULL 2 NULL
3424
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop)
3425
select * from t0 where a in (select a from t1);
3430
create table t0(a int);
3431
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3432
create table t1 as select a as a, a as b, a as c from t0 where a < 3;
3433
create table t2 as select a as a, a as b from t0 where a < 3;
3434
insert into t2 select * from t2;
3435
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);
3436
id select_type table type possible_keys key key_len ref rows Extra
3437
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
3438
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 15 test.t1.a,test.t1.b,test.t1.c 1 NULL
3439
2 MATERIALIZED X ALL NULL NULL NULL NULL 6 Using where
3440
2 MATERIALIZED Y ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop)
3441
2 MATERIALIZED Z ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop)
3442
drop table t0,t1,t2;
3443
set @save_join_buffer_size = @@join_buffer_size;
3444
set join_buffer_size= 8192;
3445
create table t0 (a int);
3446
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
3447
create table t1 (a int, filler1 binary(200), filler2 binary(200));
3448
insert into t1 select a, 'filler123456', 'filler123456' from t0;
3449
insert into t1 select a+10, 'filler123456', 'filler123456' from t0;
3450
create table t2 as select * from t1;
3451
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
3452
insert into t1 values (2, 'duplicate ok', 'duplicate ok');
3453
insert into t1 values (18, 'duplicate ok', 'duplicate ok');
3454
insert into t2 values (3, 'duplicate ok', 'duplicate ok');
3455
insert into t2 values (19, 'duplicate ok', 'duplicate ok');
3457
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
3458
from t1 ot where a in (select a from t2 it);
3459
id select_type table type possible_keys key key_len ref rows Extra
3460
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
3461
1 SIMPLE ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (Block Nested Loop)
3462
2 MATERIALIZED it ALL NULL NULL NULL NULL 22 NULL
3464
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
3465
from t1 ot where a in (select a from t2 it);
3466
a mid(filler1, 1,10) Z
3490
a, mid(filler1, 1,10), length(filler1)=length(filler2)
3491
from t2 ot where a in (select a from t1 it);
3492
id select_type table type possible_keys key key_len ref rows Extra
3493
1 SIMPLE ot ALL NULL NULL NULL NULL 22 Using where
3494
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot.a 1 NULL
3495
2 MATERIALIZED it ALL NULL NULL NULL NULL 32 NULL
3497
a, mid(filler1, 1,10), length(filler1)=length(filler2)
3498
from t2 ot where a in (select a from t1 it);
3499
a mid(filler1, 1,10) length(filler1)=length(filler2)
3522
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
3523
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
3525
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
3526
from t1 ot where a in (select a from t2 it);
3527
id select_type table type possible_keys key key_len ref rows Extra
3528
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
3529
1 SIMPLE ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (Block Nested Loop)
3530
2 MATERIALIZED it ALL NULL NULL NULL NULL 22 NULL
3532
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
3533
from t1 ot where a in (select a from t2 it);
3534
a mid(filler1, 1,10) Z
3558
a, mid(filler1, 1,10), length(filler1)=length(filler2)
3559
from t2 ot where a in (select a from t1 it);
3560
id select_type table type possible_keys key key_len ref rows Extra
3561
1 SIMPLE ot ALL NULL NULL NULL NULL 22 Using where
3562
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot.a 1 NULL
3563
2 MATERIALIZED it ALL NULL NULL NULL NULL 52 NULL
3565
a, mid(filler1, 1,10), length(filler1)=length(filler2)
3566
from t2 ot where a in (select a from t1 it);
3567
a mid(filler1, 1,10) length(filler1)=length(filler2)
3590
set @@join_buffer_size = @save_join_buffer_size;
3592
create table t1 (a int, b int, key(a));
3593
create table t2 (a int, b int, key(a));
3594
create table t3 (a int, b int, key(a));
3595
insert into t1 select a,a from t0;
3596
insert into t2 select a,a from t0;
3597
insert into t3 select a,a from t0;
3598
t2 and t3 must be use 'ref', not 'ALL':
3601
(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
3602
id select_type table type possible_keys key key_len ref rows Extra
3603
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
3604
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 9 test.t0.a 1 Using where
3605
2 MATERIALIZED t1 index a a 5 NULL 10 Using index
3606
2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index
3607
2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index
3608
drop table t0, t1,t2,t3;
3610
Test that neither MaterializeLookup strategy for semijoin,
3611
nor subquery materialization is used when BLOBs are involved
3612
(except when arguments of some functions).
3614
set @prefix_len = 6;
3616
set @suffix_len = @blob_len - @prefix_len;
3617
create table t1_16 (a1 blob(16), a2 blob(16));
3618
create table t2_16 (b1 blob(16), b2 blob(16));
3619
create table t3_16 (c1 blob(16), c2 blob(16));
3620
insert into t1_16 values
3621
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3622
insert into t1_16 values
3623
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3624
insert into t1_16 values
3625
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3626
insert into t2_16 values
3627
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3628
insert into t2_16 values
3629
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3630
insert into t2_16 values
3631
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3632
insert into t3_16 values
3633
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3634
insert into t3_16 values
3635
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3636
insert into t3_16 values
3637
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3638
insert into t3_16 values
3639
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3640
explain extended select left(a1,7), left(a2,7)
3642
where a1 in (select b1 from t2_16 where b1 > '0');
3643
id select_type table type possible_keys key key_len ref rows filtered Extra
3644
1 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3645
1 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop)
3647
Note 1003 /* select#1 */ 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` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0'))
3648
select left(a1,7), left(a2,7)
3650
where a1 in (select b1 from t2_16 where b1 > '0');
3651
left(a1,7) left(a2,7)
3654
explain extended select left(a1,7), left(a2,7)
3656
where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
3657
id select_type table type possible_keys key key_len ref rows filtered Extra
3658
1 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3659
1 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop)
3661
Note 1003 /* select#1 */ 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`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0'))
3662
select left(a1,7), left(a2,7)
3664
where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
3665
left(a1,7) left(a2,7)
3668
explain extended select left(a1,7), left(a2,7)
3670
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
3671
id select_type table type possible_keys key key_len ref rows filtered Extra
3672
1 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 NULL
3673
1 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop)
3675
Note 1003 /* select#1 */ 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)))
3676
select left(a1,7), left(a2,7)
3678
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
3679
left(a1,7) left(a2,7)
3682
explain extended select left(a1,7), left(a2,7)
3684
where a1 in (select group_concat(b1) from t2_16 group by b2);
3685
id select_type table type possible_keys key key_len ref rows filtered Extra
3686
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3687
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
3689
Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ',')))))
3690
select left(a1,7), left(a2,7)
3692
where a1 in (select group_concat(b1) from t2_16 group by b2);
3693
left(a1,7) left(a2,7)
3696
set @@group_concat_max_len = 256;
3697
explain extended select left(a1,7), left(a2,7)
3699
where a1 in (select group_concat(b1) from t2_16 group by b2);
3700
id select_type table type possible_keys key key_len ref rows filtered Extra
3701
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3702
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
3704
Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_16`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
3705
select left(a1,7), left(a2,7)
3707
where a1 in (select group_concat(b1) from t2_16 group by b2);
3708
left(a1,7) left(a2,7)
3711
create table t1 (a1 char(8), a2 char(8));
3712
create table t2 (b1 char(8), b2 char(8));
3713
create table t3 (c1 char(8), c2 char(8));
3714
insert into t1 values ('1 - 00', '2 - 00');
3715
insert into t1 values ('1 - 01', '2 - 01');
3716
insert into t1 values ('1 - 02', '2 - 02');
3717
insert into t2 values ('1 - 01', '2 - 01');
3718
insert into t2 values ('1 - 01', '2 - 01');
3719
insert into t2 values ('1 - 02', '2 - 02');
3720
insert into t2 values ('1 - 02', '2 - 02');
3721
insert into t2 values ('1 - 03', '2 - 03');
3722
insert into t3 values ('1 - 01', '2 - 01');
3723
insert into t3 values ('1 - 02', '2 - 02');
3724
insert into t3 values ('1 - 03', '2 - 03');
3725
insert into t3 values ('1 - 04', '2 - 04');
3728
where concat(a1,'x') IN
3729
(select left(a1,8) from t1_16
3731
(select t2_16.b1, t2_16.b2 from t2_16, t2
3732
where t2.b2 = substring(t2_16.b2,1,6) and
3733
t2.b1 IN (select c1 from t3 where c2 > '0')));
3734
id select_type table type possible_keys key key_len ref rows filtered Extra
3735
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Start temporary
3736
1 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop)
3737
1 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop)
3738
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop)
3739
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (Block Nested Loop)
3741
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t2`.`b1` = `test`.`t3`.`c1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8)))
3742
drop table t1_16, t2_16, t3_16, t1, t2, t3;
3743
set @blob_len = 512;
3744
set @suffix_len = @blob_len - @prefix_len;
3745
create table t1_512 (a1 blob(512), a2 blob(512));
3746
create table t2_512 (b1 blob(512), b2 blob(512));
3747
create table t3_512 (c1 blob(512), c2 blob(512));
3748
insert into t1_512 values
3749
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3750
insert into t1_512 values
3751
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3752
insert into t1_512 values
3753
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3754
insert into t2_512 values
3755
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3756
insert into t2_512 values
3757
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3758
insert into t2_512 values
3759
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3760
insert into t3_512 values
3761
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3762
insert into t3_512 values
3763
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3764
insert into t3_512 values
3765
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3766
insert into t3_512 values
3767
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3768
explain extended select left(a1,7), left(a2,7)
3770
where a1 in (select b1 from t2_512 where b1 > '0');
3771
id select_type table type possible_keys key key_len ref rows filtered Extra
3772
1 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
3773
1 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop)
3775
Note 1003 /* select#1 */ 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` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0'))
3776
select left(a1,7), left(a2,7)
3778
where a1 in (select b1 from t2_512 where b1 > '0');
3779
left(a1,7) left(a2,7)
3782
explain extended select left(a1,7), left(a2,7)
3784
where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
3785
id select_type table type possible_keys key key_len ref rows filtered Extra
3786
1 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
3787
1 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop)
3789
Note 1003 /* select#1 */ 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`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0'))
3790
select left(a1,7), left(a2,7)
3792
where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
3793
left(a1,7) left(a2,7)
3796
explain extended select left(a1,7), left(a2,7)
3798
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
3799
id select_type table type possible_keys key key_len ref rows filtered Extra
3800
1 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 NULL
3801
1 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop)
3803
Note 1003 /* select#1 */ 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)))
3804
select left(a1,7), left(a2,7)
3806
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
3807
left(a1,7) left(a2,7)
3810
explain extended select left(a1,7), left(a2,7)
3812
where a1 in (select group_concat(b1) from t2_512 group by b2);
3813
id select_type table type possible_keys key key_len ref rows filtered Extra
3814
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
3815
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
3817
Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_512`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
3818
select left(a1,7), left(a2,7)
3820
where a1 in (select group_concat(b1) from t2_512 group by b2);
3821
left(a1,7) left(a2,7)
3823
Warning 1260 Row 1 was cut by GROUP_CONCAT()
3824
Warning 1260 Row 2 was cut by GROUP_CONCAT()
3825
Warning 1260 Row 3 was cut by GROUP_CONCAT()
3826
set @@group_concat_max_len = 256;
3827
explain extended select left(a1,7), left(a2,7)
3829
where a1 in (select group_concat(b1) from t2_512 group by b2);
3830
id select_type table type possible_keys key key_len ref rows filtered Extra
3831
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
3832
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
3834
Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_512`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
3835
select left(a1,7), left(a2,7)
3837
where a1 in (select group_concat(b1) from t2_512 group by b2);
3838
left(a1,7) left(a2,7)
3840
Warning 1260 Row 1 was cut by GROUP_CONCAT()
3841
Warning 1260 Row 2 was cut by GROUP_CONCAT()
3842
Warning 1260 Row 3 was cut by GROUP_CONCAT()
3843
drop table t1_512, t2_512, t3_512;
3844
set @blob_len = 513;
3845
set @suffix_len = @blob_len - @prefix_len;
3846
create table t1_513 (a1 blob(513), a2 blob(513));
3847
create table t2_513 (b1 blob(513), b2 blob(513));
3848
create table t3_513 (c1 blob(513), c2 blob(513));
3849
insert into t1_513 values
3850
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3851
insert into t1_513 values
3852
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3853
insert into t1_513 values
3854
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3855
insert into t2_513 values
3856
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3857
insert into t2_513 values
3858
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3859
insert into t2_513 values
3860
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3861
insert into t3_513 values
3862
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3863
insert into t3_513 values
3864
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3865
insert into t3_513 values
3866
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3867
insert into t3_513 values
3868
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3869
explain extended select left(a1,7), left(a2,7)
3871
where a1 in (select b1 from t2_513 where b1 > '0');
3872
id select_type table type possible_keys key key_len ref rows filtered Extra
3873
1 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where
3874
1 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop)
3876
Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0'))
3877
select left(a1,7), left(a2,7)
3879
where a1 in (select b1 from t2_513 where b1 > '0');
3880
left(a1,7) left(a2,7)
3883
explain extended select left(a1,7), left(a2,7)
3885
where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0');
3886
id select_type table type possible_keys key key_len ref rows filtered Extra
3887
1 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where
3888
1 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop)
3890
Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0'))
3891
select left(a1,7), left(a2,7)
3893
where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0');
3894
left(a1,7) left(a2,7)
3897
explain extended select left(a1,7), left(a2,7)
3899
where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0');
3900
id select_type table type possible_keys key key_len ref rows filtered Extra
3901
1 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 NULL
3902
1 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop)
3904
Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513)))
3905
select left(a1,7), left(a2,7)
3907
where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0');
3908
left(a1,7) left(a2,7)
3911
explain extended select left(a1,7), left(a2,7)
3913
where a1 in (select group_concat(b1) from t2_513 group by b2);
3914
id select_type table type possible_keys key key_len ref rows filtered Extra
3915
1 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where
3916
2 SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using filesort
3918
Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where <in_optimizer>(`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_513`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_513`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
3919
select left(a1,7), left(a2,7)
3921
where a1 in (select group_concat(b1) from t2_513 group by b2);
3922
left(a1,7) left(a2,7)
3924
Warning 1260 Row 1 was cut by GROUP_CONCAT()
3925
Warning 1260 Row 2 was cut by GROUP_CONCAT()
3926
Warning 1260 Row 3 was cut by GROUP_CONCAT()
3927
drop table t1_513, t2_513, t3_513;
3928
set @blob_len = 1024;
3929
set @suffix_len = @blob_len - @prefix_len;
3930
create table t1_1024 (a1 blob(1024), a2 blob(1024));
3931
create table t2_1024 (b1 blob(1024), b2 blob(1024));
3932
create table t3_1024 (c1 blob(1024), c2 blob(1024));
3933
insert into t1_1024 values
3934
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3935
insert into t1_1024 values
3936
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3937
insert into t1_1024 values
3938
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3939
insert into t2_1024 values
3940
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3941
insert into t2_1024 values
3942
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3943
insert into t2_1024 values
3944
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3945
insert into t3_1024 values
3946
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3947
insert into t3_1024 values
3948
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3949
insert into t3_1024 values
3950
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3951
insert into t3_1024 values
3952
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3953
explain extended select left(a1,7), left(a2,7)
3955
where a1 in (select b1 from t2_1024 where b1 > '0');
3956
id select_type table type possible_keys key key_len ref rows filtered Extra
3957
1 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
3958
1 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop)
3960
Note 1003 /* select#1 */ 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` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0'))
3961
select left(a1,7), left(a2,7)
3963
where a1 in (select b1 from t2_1024 where b1 > '0');
3964
left(a1,7) left(a2,7)
3967
explain extended select left(a1,7), left(a2,7)
3969
where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
3970
id select_type table type possible_keys key key_len ref rows filtered Extra
3971
1 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
3972
1 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop)
3974
Note 1003 /* select#1 */ 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`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0'))
3975
select left(a1,7), left(a2,7)
3977
where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
3978
left(a1,7) left(a2,7)
3981
explain extended select left(a1,7), left(a2,7)
3983
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
3984
id select_type table type possible_keys key key_len ref rows filtered Extra
3985
1 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 NULL
3986
1 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop)
3988
Note 1003 /* select#1 */ 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)))
3989
select left(a1,7), left(a2,7)
3991
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
3992
left(a1,7) left(a2,7)
3995
explain extended select left(a1,7), left(a2,7)
3997
where a1 in (select group_concat(b1) from t2_1024 group by b2);
3998
id select_type table type possible_keys key key_len ref rows filtered Extra
3999
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
4000
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
4002
Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1024`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
4003
select left(a1,7), left(a2,7)
4005
where a1 in (select group_concat(b1) from t2_1024 group by b2);
4006
left(a1,7) left(a2,7)
4008
Warning 1260 Row 1 was cut by GROUP_CONCAT()
4009
Warning 1260 Row 2 was cut by GROUP_CONCAT()
4010
Warning 1260 Row 3 was cut by GROUP_CONCAT()
4011
set @@group_concat_max_len = 256;
4012
explain extended select left(a1,7), left(a2,7)
4014
where a1 in (select group_concat(b1) from t2_1024 group by b2);
4015
id select_type table type possible_keys key key_len ref rows filtered Extra
4016
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
4017
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
4019
Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1024`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
4020
select left(a1,7), left(a2,7)
4022
where a1 in (select group_concat(b1) from t2_1024 group by b2);
4023
left(a1,7) left(a2,7)
4025
Warning 1260 Row 1 was cut by GROUP_CONCAT()
4026
Warning 1260 Row 2 was cut by GROUP_CONCAT()
4027
Warning 1260 Row 3 was cut by GROUP_CONCAT()
4028
drop table t1_1024, t2_1024, t3_1024;
4029
set @blob_len = 1025;
4030
set @suffix_len = @blob_len - @prefix_len;
4031
create table t1_1025 (a1 blob(1025), a2 blob(1025));
4032
create table t2_1025 (b1 blob(1025), b2 blob(1025));
4033
create table t3_1025 (c1 blob(1025), c2 blob(1025));
4034
insert into t1_1025 values
4035
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
4036
insert into t1_1025 values
4037
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
4038
insert into t1_1025 values
4039
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
4040
insert into t2_1025 values
4041
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
4042
insert into t2_1025 values
4043
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
4044
insert into t2_1025 values
4045
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
4046
insert into t3_1025 values
4047
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
4048
insert into t3_1025 values
4049
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
4050
insert into t3_1025 values
4051
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
4052
insert into t3_1025 values
4053
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
4054
explain extended select left(a1,7), left(a2,7)
4056
where a1 in (select b1 from t2_1025 where b1 > '0');
4057
id select_type table type possible_keys key key_len ref rows filtered Extra
4058
1 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
4059
1 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop)
4061
Note 1003 /* select#1 */ 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` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0'))
4062
select left(a1,7), left(a2,7)
4064
where a1 in (select b1 from t2_1025 where b1 > '0');
4065
left(a1,7) left(a2,7)
4068
explain extended select left(a1,7), left(a2,7)
4070
where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
4071
id select_type table type possible_keys key key_len ref rows filtered Extra
4072
1 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
4073
1 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop)
4075
Note 1003 /* select#1 */ 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`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0'))
4076
select left(a1,7), left(a2,7)
4078
where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
4079
left(a1,7) left(a2,7)
4082
explain extended select left(a1,7), left(a2,7)
4084
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
4085
id select_type table type possible_keys key key_len ref rows filtered Extra
4086
1 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 NULL
4087
1 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop)
4089
Note 1003 /* select#1 */ 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)))
4090
select left(a1,7), left(a2,7)
4092
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
4093
left(a1,7) left(a2,7)
4096
explain extended select left(a1,7), left(a2,7)
4098
where a1 in (select group_concat(b1) from t2_1025 group by b2);
4099
id select_type table type possible_keys key key_len ref rows filtered Extra
4100
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
4101
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
4103
Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1025`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
4104
select left(a1,7), left(a2,7)
4106
where a1 in (select group_concat(b1) from t2_1025 group by b2);
4107
left(a1,7) left(a2,7)
4109
Warning 1260 Row 1 was cut by GROUP_CONCAT()
4110
Warning 1260 Row 2 was cut by GROUP_CONCAT()
4111
Warning 1260 Row 3 was cut by GROUP_CONCAT()
4112
set @@group_concat_max_len = 256;
4113
explain extended select left(a1,7), left(a2,7)
4115
where a1 in (select group_concat(b1) from t2_1025 group by b2);
4116
id select_type table type possible_keys key key_len ref rows filtered Extra
4117
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
4118
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
4120
Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1025`.`a1` = `materialized-subquery`.`group_concat(b1)`)))))
4121
select left(a1,7), left(a2,7)
4123
where a1 in (select group_concat(b1) from t2_1025 group by b2);
4124
left(a1,7) left(a2,7)
4126
Warning 1260 Row 1 was cut by GROUP_CONCAT()
4127
Warning 1260 Row 2 was cut by GROUP_CONCAT()
4128
Warning 1260 Row 3 was cut by GROUP_CONCAT()
4129
drop table t1_1025, t2_1025, t3_1025;
4131
# WL#5561: Enable semi join transformation with outer join.
4133
CREATE TABLE ot1(a INT);
4134
CREATE TABLE ot2(a INT);
4135
CREATE TABLE ot3(a INT);
4136
CREATE TABLE it1(a INT);
4137
CREATE TABLE it2(a INT);
4138
CREATE TABLE it3(a INT);
4139
INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
4140
INSERT INTO ot2 VALUES(0),(2),(4),(6);
4141
INSERT INTO ot3 VALUES(0),(3),(6);
4142
INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
4143
INSERT INTO it2 VALUES(0),(2),(4),(6);
4144
INSERT INTO it3 VALUES(0),(3),(6);
4145
# Test cases, Subquery Pattern 1
4148
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4149
WHERE ot1.a IN (SELECT a FROM it3);
4150
id select_type table type possible_keys key key_len ref rows Extra
4151
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
4152
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4153
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4154
2 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL
4156
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4157
WHERE ot1.a IN (SELECT a FROM it3);
4164
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4165
WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);
4166
id select_type table type possible_keys key key_len ref rows Extra
4167
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
4168
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using join buffer (Block Nested Loop)
4169
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4170
2 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL
4172
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4173
WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);
4183
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4184
WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
4185
id select_type table type possible_keys key key_len ref rows Extra
4186
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where
4187
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4188
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4189
2 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL
4191
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4192
WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
4198
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0
4199
WHERE ot1.a IN (SELECT a FROM it3);
4205
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0
4206
WHERE ot1.a IN (SELECT a+0 FROM it3);
4212
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0
4213
WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);
4222
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4223
WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3);
4232
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0
4233
WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
4238
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4239
LEFT JOIN ot3 ON ot1.a=ot3.a
4240
WHERE ot1.a IN (SELECT a FROM it3);
4246
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4247
LEFT JOIN ot3 ON ot1.a=ot3.a
4248
WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);
4257
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4258
LEFT JOIN ot3 ON ot1.a=ot3.a
4259
WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3);
4270
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4271
LEFT JOIN ot3 ON ot2.a=ot3.a
4272
WHERE ot1.a IN (SELECT a FROM it3);
4278
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4279
LEFT JOIN ot3 ON ot2.a=ot3.a
4280
WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);
4289
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
4290
LEFT JOIN ot3 ON ot2.a=ot3.a
4291
WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3);
4301
# Test cases, Subquery Pattern 2
4304
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3);
4305
id select_type table type possible_keys key key_len ref rows Extra
4306
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
4307
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4308
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4309
2 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL
4311
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3);
4317
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2)
4318
AND ot2.a IN (SELECT a FROM it3);
4319
id select_type table type possible_keys key key_len ref rows Extra
4320
1 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using where
4321
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4322
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4323
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 <subquery3>.a 1 NULL
4324
3 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL
4325
2 MATERIALIZED it2 ALL NULL NULL NULL NULL 4 NULL
4327
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2)
4328
AND ot2.a IN (SELECT a FROM it3);
4334
FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3);
4339
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3);
4344
FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3);
4349
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3);
4354
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2)
4355
AND ot2.a IN (SELECT a+0 FROM it3);
4360
FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3)
4361
JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3);
4365
# Test cases, Subquery Pattern 3
4368
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3);
4369
id select_type table type possible_keys key key_len ref rows Extra
4370
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
4371
1 SIMPLE it3 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(ot1)
4372
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4374
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3);
4386
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2);
4387
id select_type table type possible_keys key key_len ref rows Extra
4388
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
4389
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4390
1 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot2)
4392
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2);
4404
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1)
4405
AND ot2.a IN (SELECT a FROM it2);
4406
id select_type table type possible_keys key key_len ref rows Extra
4407
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
4408
1 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1)
4409
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4410
1 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot2)
4412
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1)
4413
AND ot2.a IN (SELECT a FROM it2);
4425
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND
4426
(ot1.a, ot2.a) IN (SELECT it1.a, it2.a
4427
FROM it1 JOIN it2 ON it1.a=it2.a);
4428
id select_type table type possible_keys key key_len ref rows Extra
4429
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Start temporary
4430
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4431
1 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4432
1 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (Block Nested Loop)
4434
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND
4435
(ot1.a, ot2.a) IN (SELECT it1.a, it2.a
4436
FROM it1 JOIN it2 ON it1.a=it2.a);
4448
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3);
4459
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3);
4470
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2);
4481
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2);
4492
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1)
4493
AND ot2.a IN (SELECT a+0 FROM it2);
4504
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND
4505
(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0
4506
FROM it1 JOIN it2 ON it1.a=it2.a);
4517
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3)
4518
LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3);
4529
FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3)
4530
LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3);
4540
# Test cases, Subquery Pattern 4
4545
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4546
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4547
id select_type table type possible_keys key key_len ref rows Extra
4548
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
4549
1 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1)
4550
1 SIMPLE ot3 ALL NULL NULL NULL NULL 3 NULL
4551
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4555
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4556
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4570
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4571
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4572
id select_type table type possible_keys key key_len ref rows Extra
4573
1 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where
4574
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
4575
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4576
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot3.a 1 NULL
4577
2 MATERIALIZED it1 ALL NULL NULL NULL NULL 8 NULL
4581
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4582
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4590
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4591
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4592
id select_type table type possible_keys key key_len ref rows Extra
4593
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4594
1 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop)
4595
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
4596
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot2.a 1 NULL
4597
2 MATERIALIZED it1 ALL NULL NULL NULL NULL 8 NULL
4601
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4602
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4612
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4613
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4614
id select_type table type possible_keys key key_len ref rows Extra
4615
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
4616
1 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1)
4617
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
4618
1 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where
4622
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4623
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4637
(ot2 JOIN ot3 ON ot2.a=ot3.a+0)
4638
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4651
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4652
ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1);
4665
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4666
ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1);
4679
(ot2 JOIN ot3 ON ot2.a=ot3.a+0)
4680
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4687
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4688
ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1);
4695
(ot2 JOIN ot3 ON ot2.a=ot3.a)
4696
ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1);
4703
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0)
4704
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4713
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4714
ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1);
4723
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4724
ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1);
4733
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0)
4734
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4747
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4748
ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1);
4761
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4762
ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1);
4775
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a)
4776
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1)
4792
(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a
4793
LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a)
4794
ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1);
4804
DROP TABLE ot1,ot2,ot3,it1,it2,it3;
4806
a INTEGER DEFAULT NULL
4808
INSERT INTO t VALUES (1);
4810
a INTEGER DEFAULT NULL
4812
INSERT INTO t2 VALUES (1),(1);
4814
a INTEGER DEFAULT NULL
4816
INSERT INTO t4 VALUES (1),(1);
4818
a INTEGER DEFAULT NULL
4820
INSERT INTO v VALUES (1),(1);
4826
ON t3.a IN (SELECT a FROM t AS it)
4831
WHERE t1.a IN (SELECT * FROM v AS it2);
4832
id select_type table type possible_keys key key_len ref rows Extra
4833
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 NULL
4834
1 SIMPLE it2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop)
4835
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
4836
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where
4837
1 SIMPLE it ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t3)
4838
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where
4844
ON t3.a IN (SELECT a FROM t AS it)
4849
WHERE t1.a IN (SELECT * FROM v AS it2);
4852
DROP TABLE t,t2,t4,v;
4855
# Bug#48868: Left outer join in subquery causes segmentation fault in
4858
CREATE TABLE t1 (i INTEGER);
4859
INSERT INTO t1 VALUES (1);
4860
INSERT INTO t1 VALUES (2);
4861
CREATE TABLE t2 (i INTEGER);
4862
INSERT INTO t2 VALUES(1);
4863
CREATE TABLE t3 (i INTEGER);
4864
INSERT INTO t3 VALUES (1);
4865
INSERT INTO t3 VALUES (2);
4866
SELECT * FROM t1 WHERE (t1.i) IN
4867
(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
4870
DROP TABLE t1, t2, t3;
4872
Bug#37899: Wrongly checked optimization prerequisite caused failed
4877
`varchar_nokey` varchar(5)
4879
INSERT INTO t1 VALUES
4880
(1,'qk'),(2,'j'),(3,'aew');
4883
WHERE varchar_nokey IN (
4895
# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING
4898
pk int(11) NOT NULL AUTO_INCREMENT,
4899
int_nokey int(11) NOT NULL,
4900
time_key time NOT NULL,
4901
datetime_key datetime NOT NULL,
4902
datetime_nokey datetime NOT NULL,
4903
varchar_key varchar(1) NOT NULL,
4904
varchar_nokey varchar(1) NOT NULL,
4906
KEY time_key (time_key),
4907
KEY datetime_key (datetime_key),
4908
KEY varchar_key (varchar_key)
4910
INSERT INTO t1 VALUES
4911
(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'),
4912
(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''),
4913
(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'),
4914
(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'),
4915
(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),
4916
(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'),
4917
(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''),
4918
(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'),
4919
(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'),
4920
(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'),
4921
(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
4922
(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''),
4923
(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'),
4924
(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
4925
(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'),
4926
(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'),
4927
(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'),
4928
(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'),
4929
(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'),
4930
(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k');
4932
pk int(11) NOT NULL AUTO_INCREMENT,
4933
int_nokey int(11) NOT NULL,
4934
time_key time NOT NULL,
4935
datetime_key datetime NOT NULL,
4936
datetime_nokey datetime NOT NULL,
4937
varchar_key varchar(1) NOT NULL,
4938
varchar_nokey varchar(1) NOT NULL,
4940
KEY time_key (time_key),
4941
KEY datetime_key (datetime_key),
4942
KEY varchar_key (varchar_key)
4944
INSERT INTO t2 VALUES
4945
(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),
4946
(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b');
4947
SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR
4949
OUTR.varchar_nokey IN (SELECT
4950
INNR . varchar_nokey AS Y
4953
INNR . datetime_key >= INNR . time_key OR
4954
INNR . pk = INNR . int_nokey
4956
AND OUTR . varchar_nokey <= 'w'
4957
HAVING X > '2012-12-12';
4961
Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order
4965
varchar_key varchar(1) DEFAULT NULL,
4966
KEY varchar_key (varchar_key)
4969
varchar_key varchar(1) DEFAULT NULL,
4970
KEY varchar_key (varchar_key)
4972
INSERT INTO t2 VALUES
4973
(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'),
4974
('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'),
4975
('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'),
4976
('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'),
4977
('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'),
4978
('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'),
4979
('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'),
4980
('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z');
4982
varchar_key varchar(1) DEFAULT NULL,
4983
KEY varchar_key (varchar_key)
4984
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
4985
INSERT INTO t3 VALUES
4986
(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'),
4987
('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y');
4988
SELECT varchar_key FROM t3
4989
WHERE (SELECT varchar_key FROM t3
4990
WHERE (varchar_key,varchar_key)
4991
IN (SELECT t1.varchar_key, t2 .varchar_key
4992
FROM t1 RIGHT JOIN t2 ON t1.varchar_key
4996
DROP TABLE t1, t2, t3;
4998
# Bug#46556 Returning incorrect, empty results for some IN subqueries
5009
VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n');
5010
EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN
5011
(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey);
5012
id select_type table type possible_keys key key_len ref rows filtered Extra
5013
1 SIMPLE t0 ALL PRIMARY NULL NULL NULL 5 100.00 NULL
5014
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using join buffer (Batched Key Access (unique))
5015
1 SIMPLE t2 index vkey vkey 4 NULL 5 80.00 Using where; Using index; FirstMatch(t1); Using join buffer (Block Nested Loop)
5017
Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`))
5018
SELECT vkey FROM t0 WHERE pk IN
5019
(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey);
5029
Bug#48834: Procedure with view + subquery + semijoin=on
5030
crashes on second call.
5032
CREATE TABLE t1 ( t1field integer, primary key (t1field));
5033
CREATE TABLE t2 ( t2field integer, primary key (t2field));
5035
SELECT t1field as v1field
5037
WHERE A.t1field IN (SELECT t1field FROM t2 );
5039
SELECT t2field as v2field
5041
WHERE A.t2field IN (SELECT t2field FROM t2 );
5042
CREATE PROCEDURE p1 ()
5046
WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 );
5048
INSERT INTO t1 VALUES (1),(2),(3);
5049
INSERT INTO t2 VALUES (2),(3),(4);
5063
# Bug#46692 "Crash occurring on queries with nested FROM subqueries
5064
# using materialization."
5067
pk INTEGER PRIMARY KEY,
5069
KEY int_key(int_key)
5071
INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1);
5073
pk INTEGER PRIMARY KEY,
5075
KEY int_key(int_key)
5077
INSERT INTO t2 VALUES (1,7),(2,2);
5078
SELECT * FROM t1 WHERE (140, 4) IN
5079
(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key);
5083
# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query
5087
pk INTEGER PRIMARY KEY,
5091
datetime_nokey DATETIME,
5092
varchar_nokey VARCHAR(1)
5098
pk INTEGER PRIMARY KEY,
5101
varchar_key VARCHAR(1),
5102
varchar_nokey VARCHAR(1),
5103
KEY date_key (date_key)
5105
SELECT date_key FROM t1
5106
WHERE (int_key, int_nokey)
5107
IN (SELECT t3.int_nokey, t3.pk
5108
FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key)
5109
WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk
5111
AND (varchar_nokey <> 'f' OR NOT int_key < 7);
5114
# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery
5115
# + AND in outer query".
5117
INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'),
5118
(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'),
5119
(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'),
5120
(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'),
5121
(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'),
5122
(15,6,5,'2001-11-12','0000-00-00 00:00:00',''),
5123
(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'),
5124
(29,9,1,'0000-00-00','2003-08-11 00:00:00','m');
5125
INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'),
5126
(2,2,'2002-09-17','h','h');
5127
SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey
5128
WHERE t1.varchar_nokey
5129
IN (SELECT varchar_nokey FROM t1
5131
IN (SELECT t3.int_nokey
5132
FROM t3 LEFT JOIN t1 ON t1.varchar_nokey
5133
WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26'
5137
DROP TABLE t1, t2, t3;
5139
# Bug#45219 "Crash on SELECT DISTINCT query containing a
5140
# LEFT JOIN in subquery"
5143
pk INTEGER NOT NULL,
5144
int_nokey INTEGER NOT NULL,
5145
datetime_key DATETIME NOT NULL,
5146
varchar_key VARCHAR(1) NOT NULL,
5148
KEY datetime_key (datetime_key),
5149
KEY varchar_key (varchar_key)
5151
INSERT INTO t1 VALUES
5152
(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'),
5153
(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'),
5154
(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'),
5155
(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'),
5156
(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'),
5157
(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'),
5158
(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'),
5159
(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'),
5160
(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''),
5161
(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u');
5162
CREATE TABLE t2 LIKE t1;
5163
INSERT INTO t2 VALUES
5164
(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'),
5165
(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'),
5166
(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''),
5167
(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'),
5168
(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'),
5169
(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'),
5170
(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''),
5171
(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'),
5172
(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'),
5173
(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x');
5174
CREATE TABLE t3 LIKE t1;
5175
INSERT INTO t3 VALUES
5176
(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51','');
5177
SELECT DISTINCT datetime_key FROM t1
5178
WHERE (int_nokey, pk)
5179
IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
5182
DROP TABLE t1, t2, t3;
5184
# Bug#46550 Azalea returning duplicate results for some IN subqueries
5187
DROP TABLE IF EXISTS t0, t1, t2;
5189
int_key int(11) DEFAULT NULL,
5190
varchar_key varchar(1) DEFAULT NULL,
5191
varchar_nokey varchar(1) DEFAULT NULL,
5192
KEY int_key (int_key),
5193
KEY varchar_key (varchar_key,int_key)
5195
INSERT INTO t0 VALUES
5217
int_key int(11) DEFAULT NULL,
5218
varchar_key varchar(1) DEFAULT NULL,
5219
varchar_nokey varchar(1) DEFAULT NULL,
5220
KEY int_key (int_key),
5221
KEY varchar_key (varchar_key,int_key)
5223
INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x');
5225
int_key int(11) DEFAULT NULL,
5226
varchar_key varchar(1) DEFAULT NULL,
5227
varchar_nokey varchar(1) DEFAULT NULL,
5228
KEY int_key (int_key),
5229
KEY varchar_key (varchar_key,int_key)
5231
INSERT INTO t2 VALUES (123,NULL,NULL);
5234
WHERE varchar_nokey IN (
5235
SELECT t1 .varchar_key from t1
5242
WHERE t0.varchar_nokey IN (
5243
SELECT t1_1 .varchar_key
5244
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
5252
WHERE t0.varchar_nokey IN (
5253
SELECT t1_1 .varchar_key
5254
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
5256
id select_type table type possible_keys key key_len ref rows Extra
5257
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
5258
1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop)
5259
2 MATERIALIZED t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index
5260
2 MATERIALIZED t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop)
5263
WHERE t0.varchar_nokey IN (
5264
SELECT t1_1 .varchar_key
5265
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
5273
WHERE t0.varchar_nokey IN (
5274
SELECT t1_1 .varchar_key
5275
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
5277
id select_type table type possible_keys key key_len ref rows Extra
5278
1 SIMPLE t2 system NULL NULL NULL NULL 1 NULL
5279
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
5280
1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop)
5281
2 MATERIALIZED t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index
5282
2 MATERIALIZED t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop)
5283
DROP TABLE t0, t1, t2;
5286
Bug #48073 Subquery on char columns from view crashes Mysql
5288
DROP TABLE IF EXISTS t1, t2;
5289
DROP VIEW IF EXISTS v1;
5291
city VARCHAR(50) NOT NULL,
5292
country_id SMALLINT UNSIGNED NOT NULL
5294
INSERT INTO t1 VALUES
5301
country_id SMALLINT UNSIGNED NOT NULL,
5302
country VARCHAR(50) NOT NULL
5304
INSERT INTO t2 VALUES
5306
(3,'American Samoa') ;
5308
SELECT country_id, country
5310
WHERE LEFT(country,1) = "A"
5312
SELECT city, country_id
5317
WHERE LEFT(country, 1) = "A"
5321
SELECT city, country_id
5333
Bug#49097 subquery with view generates wrong result with
5334
non-prepared statement
5336
DROP TABLE IF EXISTS t1, t2;
5337
DROP VIEW IF EXISTS v1;
5339
city VARCHAR(50) NOT NULL,
5340
country_id SMALLINT UNSIGNED NOT NULL
5342
INSERT INTO t1 VALUES
5349
country_id SMALLINT UNSIGNED NOT NULL,
5350
country VARCHAR(50) NOT NULL
5352
INSERT INTO t2 VALUES
5354
(3,'XAmerican Samoa') ;
5356
SELECT country_id, country
5358
WHERE LEFT(country,1) = "A"
5360
SELECT city, country_id
5362
WHERE country_id IN (
5365
WHERE LEFT(country,1) = "A"
5372
SELECT city, country_id
5374
WHERE country_id IN (
5385
SELECT city, country_id
5387
WHERE country_id IN (
5398
deallocate prepare stmt;
5403
# Bug#49198 Wrong result for second call of procedure
5404
# with view in subselect.
5406
CREATE TABLE t1 (t1field integer, primary key (t1field));
5407
CREATE TABLE t2 (t2field integer, primary key (t2field));
5408
CREATE TABLE t3 (t3field integer, primary key (t3field));
5409
CREATE VIEW v2 AS SELECT * FROM t2;
5410
CREATE VIEW v3 AS SELECT * FROM t3;
5411
INSERT INTO t1 VALUES(1),(2);
5412
INSERT INTO t2 VALUES(1),(2);
5413
INSERT INTO t3 VALUES(1),(2);
5418
WHERE t1field IN (SELECT * FROM v2);
5433
WHERE t1field IN (SELECT * FROM v2)
5434
AND t1field IN (SELECT * FROM v3)
5437
id select_type table type possible_keys key key_len ref rows Extra
5438
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
5439
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5440
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5442
id select_type table type possible_keys key key_len ref rows Extra
5443
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
5444
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5445
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5446
DROP TABLE t1, t2, t3;
5450
# Bug#48623 Multiple subqueries are optimized incorrectly
5452
CREATE TABLE ot(val VARCHAR(10));
5453
CREATE TABLE it1(val VARCHAR(10));
5454
CREATE TABLE it2(val VARCHAR(10));
5455
INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp');
5456
INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp');
5457
INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp');
5461
WHERE ot.val IN (SELECT it1.val FROM it1
5462
WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%')
5463
AND ot.val IN (SELECT it2.val FROM it2
5464
WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%');
5465
id select_type table type possible_keys key key_len ref rows Extra
5466
1 SIMPLE ot ALL NULL NULL NULL NULL 5 Using where
5467
1 SIMPLE <subquery3> eq_ref <auto_key> <auto_key> 13 test.ot.val 1 NULL
5468
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 13 test.ot.val 1 NULL
5469
3 MATERIALIZED it2 ALL NULL NULL NULL NULL 5 Using where
5470
2 MATERIALIZED it1 ALL NULL NULL NULL NULL 6 Using where
5473
WHERE ot.val IN (SELECT it1.val FROM it1
5474
WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%')
5475
AND ot.val IN (SELECT it2.val FROM it2
5476
WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%');
5485
# Bug #51487 Assertion failure when semi-join flattening occurs
5486
# for a subquery in HAVING
5488
CREATE TABLE t1 (a INT, b INT);
5489
INSERT INTO t1 VALUES (1,10),(2,11),(1,13);
5490
CREATE TABLE t2 AS SELECT * FROM t1;
5491
CREATE TABLE t3 AS SELECT * FROM t1;
5492
SELECT COUNT(*) FROM t1
5494
HAVING t1.a IN (SELECT t3.a FROM t3
5495
WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a));
5499
DROP TABLE t1, t2, t3;
5502
# BUG#38075: Wrong result: rows matching a subquery with outer join not returned
5504
DROP TABLE IF EXISTS ot1, it1, it2;
5506
int_key int(11) NOT NULL,
5507
datetime_key datetime NOT NULL,
5508
KEY int_key (int_key),
5509
KEY datetime_key (datetime_key)
5511
INSERT INTO it2 VALUES
5512
(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'),
5513
(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'),
5514
(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'),
5515
(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'),
5516
(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'),
5517
(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'),
5518
(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'),
5519
(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'),
5520
(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'),
5521
(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00');
5523
int_nokey int(11) NOT NULL,
5524
int_key int(11) NOT NULL,
5525
KEY int_key (int_key)
5527
INSERT INTO ot1 VALUES
5528
(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7),
5529
(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5);
5531
int_nokey int(11) NOT NULL,
5532
int_key int(11) NOT NULL,
5533
KEY int_key (int_key)
5535
INSERT INTO it1 VALUES
5537
SELECT int_key FROM ot1
5538
WHERE int_nokey IN (SELECT it2.int_key
5539
FROM it1 LEFT JOIN it2 ON it2.datetime_key);
5559
SELECT int_key FROM ot1
5560
WHERE int_nokey IN (SELECT it2.int_key
5561
FROM it1 LEFT JOIN it2 ON it2.datetime_key);
5562
id select_type table type possible_keys key key_len ref rows Extra
5563
1 SIMPLE it1 index NULL int_key 4 NULL 2 Using index; Start temporary
5564
1 SIMPLE ot1 ALL NULL NULL NULL NULL 20 Using join buffer (Block Nested Loop)
5565
1 SIMPLE it2 ref int_key int_key 4 test.ot1.int_nokey 2 Using where; End temporary; Using join buffer (Batched Key Access (unique))
5566
DROP TABLE ot1, it1, it2;
5569
# BUG#50089: Second call of procedure with view in subselect crashes server
5571
CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field));
5573
SELECT t1field AS v1field
5575
WHERE a.t1field IN (SELECT t1field FROM t1);
5576
INSERT INTO t1 VALUES(1),(2);
5579
WHERE t1field IN (SELECT v1field FROM v1);
5586
WHERE t1field IN (SELECT v1field FROM v1);
5587
id select_type table type possible_keys key key_len ref rows Extra
5588
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
5589
1 SIMPLE a eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5590
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5592
FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1);
5601
WHERE t1field IN (SELECT v1field FROM v1);
5602
id select_type table type possible_keys key key_len ref rows Extra
5603
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
5604
1 SIMPLE a eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5605
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index
5606
CREATE PROCEDURE p1()
5610
WHERE t1field IN (SELECT v1field FROM v1);
5624
WHERE t1field IN (SELECT v1field FROM v1);
5639
# Bug#45191: Incorrectly initialized semi-join led to a wrong result.
5641
CREATE TABLE STAFF (EMPNUM CHAR(3) NOT NULL,
5642
EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15));
5643
CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL,
5644
PNAME CHAR(20), PTYPE CHAR(6),
5647
CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL,
5648
PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5));
5649
INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
5650
INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
5651
INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
5652
INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
5653
INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
5654
INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale');
5655
INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna');
5656
INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa');
5657
INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale');
5658
INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna');
5659
INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale');
5660
INSERT INTO WORKS VALUES ('E1','P1',40);
5661
INSERT INTO WORKS VALUES ('E1','P2',20);
5662
INSERT INTO WORKS VALUES ('E1','P3',80);
5663
INSERT INTO WORKS VALUES ('E1','P4',20);
5664
INSERT INTO WORKS VALUES ('E1','P5',12);
5665
INSERT INTO WORKS VALUES ('E1','P6',12);
5666
INSERT INTO WORKS VALUES ('E2','P1',40);
5667
INSERT INTO WORKS VALUES ('E2','P2',80);
5668
INSERT INTO WORKS VALUES ('E3','P2',20);
5669
INSERT INTO WORKS VALUES ('E4','P2',20);
5670
INSERT INTO WORKS VALUES ('E4','P4',40);
5671
INSERT INTO WORKS VALUES ('E4','P5',80);
5672
explain SELECT EMPNUM, EMPNAME
5675
(SELECT EMPNUM FROM WORKS
5677
(SELECT PNUM FROM PROJ));
5678
id select_type table type possible_keys key key_len ref rows Extra
5679
1 SIMPLE STAFF ALL NULL NULL NULL NULL 5 Using where
5680
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.STAFF.EMPNUM 1 NULL
5681
2 MATERIALIZED PROJ ALL NULL NULL NULL NULL 6 NULL
5682
2 MATERIALIZED WORKS ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
5683
SELECT EMPNUM, EMPNAME
5686
(SELECT EMPNUM FROM WORKS
5688
(SELECT PNUM FROM PROJ));
5694
drop table STAFF,WORKS,PROJ;
5697
# BUG#36896: Server crash on SELECT FROM DUAL
5699
create table t1 (a int);
5700
select 1 as res from dual where (1) in (select * from t1);
5704
BUG#40118 Crash when running Batched Key Access and requiring one match for each key
5706
create table t0(a int);
5707
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
5708
create table t1 (a int, key(a));
5709
insert into t1 select * from t0;
5710
alter table t1 add b int not null, add filler char(200);
5711
insert into t1 select * from t1;
5712
insert into t1 select * from t1;
5713
select * from t0 where t0.a in (select t1.a from t1 where t1.b=0);
5727
# BUG#32665 Query with dependent subquery is too slow
5730
idIndividual int primary key
5732
insert into t1 values (1),(2);
5734
idContact int primary key,
5738
insert into t2 values (1,1,1),(2,2,2),(3,3,3);
5740
idAddress int primary key,
5742
postalStripped varchar(100)
5744
insert into t3 values (1,1, 'foo'), (2,2,'bar');
5745
The following must be converted to a semi-join:
5746
explain extended SELECT a.idIndividual FROM t1 a
5747
WHERE a.idIndividual IN
5748
( SELECT c.idObj FROM t3 cona
5749
INNER JOIN t2 c ON c.idContact=cona.idContact
5750
WHERE cona.postalStripped='T2H3B2'
5752
id select_type table type possible_keys key key_len ref rows filtered Extra
5753
1 SIMPLE cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
5754
1 SIMPLE c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where; Using join buffer (Batched Key Access (unique))
5755
1 SIMPLE a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary
5757
Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2'))
5758
drop table t1,t2,t3;
5759
CREATE TABLE t1 (one int, two int, flag char(1));
5760
CREATE TABLE t2 (one int, two int, flag char(1));
5761
INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
5762
INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
5764
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N');
5769
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
5773
insert into t2 values (null,null,'N');
5774
insert into t2 values (null,3,'0');
5775
insert into t2 values (null,5,'0');
5776
insert into t2 values (10,null,'0');
5777
insert into t1 values (10,3,'0');
5778
insert into t1 values (10,5,'0');
5779
insert into t1 values (10,10,'0');
5780
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
5790
SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
5794
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
5804
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
5814
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
5824
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
5825
id select_type table type possible_keys key key_len ref rows filtered Extra
5826
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL
5827
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
5829
Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)), true) and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`one`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1`
5830
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
5831
id select_type table type possible_keys key key_len ref rows filtered Extra
5832
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
5833
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t1.one,test.t1.two 1 100.00 NULL
5834
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 9 100.00 Using where
5836
Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`two` = `test`.`t1`.`two`) and (`<subquery2>`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
5837
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;
5838
id select_type table type possible_keys key key_len ref rows filtered Extra
5839
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL
5840
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
5842
Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)), true) and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`one`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1`
5844
CREATE TABLE t1 (a char(5), b char(5));
5845
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');
5846
SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb'));
5850
CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
5851
INSERT INTO t1 VALUES ('a', 'aa');
5852
INSERT INTO t1 VALUES ('a', 'aaa');
5853
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
5855
CREATE INDEX I1 ON t1 (a);
5856
CREATE INDEX I2 ON t1 (b);
5857
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
5858
id select_type table type possible_keys key key_len ref rows Extra
5859
1 SIMPLE t1 index I1 I1 2 NULL 2 Using index; LooseScan
5860
1 SIMPLE t1 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
5861
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
5863
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
5864
INSERT INTO t2 SELECT * FROM t1;
5865
CREATE INDEX I1 ON t2 (a);
5866
CREATE INDEX I2 ON t2 (b);
5867
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
5868
id select_type table type possible_keys key key_len ref rows Extra
5869
1 SIMPLE t2 index I1 I1 4 NULL 2 Using index; LooseScan
5870
1 SIMPLE t2 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
5871
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
5874
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
5875
id select_type table type possible_keys key key_len ref rows Extra
5876
1 SIMPLE t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan
5877
1 SIMPLE t1 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
5878
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
5882
# BUG#45928 "Differing query results depending on MRR and
5883
# engine_condition_pushdown settings"
5886
`pk` int(11) NOT NULL AUTO_INCREMENT,
5887
`time_nokey` time NOT NULL,
5888
`varchar_key` varchar(1) NOT NULL,
5889
`varchar_nokey` varchar(1) NOT NULL,
5891
KEY `varchar_key` (`varchar_key`)
5892
) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
5893
INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','','');
5894
SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN (
5895
SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER
5900
# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(),
5901
# file item.cc, line 4448"
5903
DROP TABLE IF EXISTS C, BB;
5905
varchar_nokey varchar(1) NOT NULL
5907
INSERT INTO C VALUES
5908
('k'),('a'),(''),('u'),('e'),('v'),('i'),
5909
('t'),('u'),('f'),('u'),('m'),('j'),('f'),
5910
('v'),('j'),('g'),('e'),('h'),('z');
5912
varchar_nokey varchar(1) NOT NULL
5914
INSERT INTO BB VALUES ('i'),('t');
5915
SELECT varchar_nokey FROM C
5916
WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey
5918
ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery'
5919
SELECT varchar_nokey FROM C
5920
WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey
5922
ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery'
5925
# During work with BUG#45863 I had problems with a query that was
5926
# optimized differently in regular and prepared mode.
5927
# Because there was a bug in one of the selected strategies, I became
5928
# aware of the problem. Adding an EXPLAIN query to catch this.
5929
DROP TABLE IF EXISTS t1, t2, t3;
5931
(EMPNUM CHAR(3) NOT NULL,
5936
(PNUM CHAR(3) NOT NULL,
5942
(EMPNUM CHAR(3) NOT NULL,
5943
PNUM CHAR(3) NOT NULL,
5945
INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
5946
INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
5947
INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
5948
INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
5949
INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
5950
INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
5951
INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
5952
INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
5953
INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
5954
INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
5955
INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
5956
INSERT INTO t3 VALUES ('E1','P1',40);
5957
INSERT INTO t3 VALUES ('E1','P2',20);
5958
INSERT INTO t3 VALUES ('E1','P3',80);
5959
INSERT INTO t3 VALUES ('E1','P4',20);
5960
INSERT INTO t3 VALUES ('E1','P5',12);
5961
INSERT INTO t3 VALUES ('E1','P6',12);
5962
INSERT INTO t3 VALUES ('E2','P1',40);
5963
INSERT INTO t3 VALUES ('E2','P2',80);
5964
INSERT INTO t3 VALUES ('E3','P2',20);
5965
INSERT INTO t3 VALUES ('E4','P2',20);
5966
INSERT INTO t3 VALUES ('E4','P4',40);
5967
INSERT INTO t3 VALUES ('E4','P5',80);
5968
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
5969
EXPLAIN SELECT EMPNAME
5977
WHERE PTYPE = 'Design'));
5978
id select_type table type possible_keys key key_len ref rows Extra
5979
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
5980
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
5981
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
5982
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
5983
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
5991
WHERE PTYPE = 'Design'))";
5993
id select_type table type possible_keys key key_len ref rows Extra
5994
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
5995
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
5996
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
5997
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
5999
id select_type table type possible_keys key key_len ref rows Extra
6000
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
6001
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6002
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6003
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6004
DEALLOCATE PREPARE stmt;
6005
DROP INDEX t1_IDX ON t1;
6006
CREATE INDEX t1_IDX ON t1(EMPNUM);
6007
EXPLAIN SELECT EMPNAME
6015
WHERE PTYPE = 'Design'));
6016
id select_type table type possible_keys key key_len ref rows Extra
6017
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
6018
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6019
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6020
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6021
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
6029
WHERE PTYPE = 'Design'))";
6031
id select_type table type possible_keys key key_len ref rows Extra
6032
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
6033
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6034
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6035
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6037
id select_type table type possible_keys key key_len ref rows Extra
6038
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where
6039
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6040
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6041
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6042
DEALLOCATE PREPARE stmt;
6043
DROP INDEX t1_IDX ON t1;
6044
EXPLAIN SELECT EMPNAME
6052
WHERE PTYPE = 'Design'));
6053
id select_type table type possible_keys key key_len ref rows Extra
6054
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
6055
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6056
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6057
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6058
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
6066
WHERE PTYPE = 'Design'))";
6068
id select_type table type possible_keys key key_len ref rows Extra
6069
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
6070
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6071
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6072
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6074
id select_type table type possible_keys key key_len ref rows Extra
6075
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
6076
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL
6077
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where
6078
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop)
6079
DEALLOCATE PREPARE stmt;
6080
DROP TABLE t1, t2, t3;
6082
# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing
6088
KEY i1_index (i1_key)
6090
INSERT INTO t1 VALUES (9,1,2), (9,2,1);
6096
INSERT INTO t2 VALUES (9,1);
6103
WHERE t1.i2 < t1.i3 XOR t2.i1 > 1
6104
ORDER BY t1.i2 desc);
6108
# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result
6113
INSERT INTO t1 VALUES(10),(20);
6114
create table t2 select * from t1;
6115
create table t3 select * from t1;
6125
explain extended SELECT *
6131
id select_type table type possible_keys key key_len ref rows filtered Extra
6132
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6133
1 SIMPLE <subquery2> const <auto_key> <auto_key> 4 const 1 100.00 NULL
6134
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 NULL
6135
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop)
6137
Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where 1
6140
INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90);
6141
insert into t2 select * from t1;
6142
insert into t3 select * from t1;
6143
create table t4 select * from t1;
6170
id select_type table type possible_keys key key_len ref rows Extra
6171
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 NULL
6172
1 SIMPLE <subquery2> const <auto_key> <auto_key> 4 const 1 NULL
6173
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 9 NULL
6174
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 9 Using join buffer (Block Nested Loop)
6175
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 9 Using join buffer (Block Nested Loop)
6194
drop table t1,t2,t3,t4;
6196
# Bug#53236 Segfault in DTCollation::set(DTCollation&)
6199
pk INTEGER AUTO_INCREMENT,
6200
col_varchar VARCHAR(1),
6204
INSERT INTO t1 (col_varchar)
6210
FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
6211
table2.col_varchar) )
6212
WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
6213
SUBQUERY1_t1.pk AS SUBQUERY1_field2
6214
FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
6215
ON (SUBQUERY1_t2.col_varchar =
6216
SUBQUERY1_t1.col_varchar) ) )
6221
# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)"
6223
create table t1 (uid int, fid int);
6224
insert into t1 values (1,1), (3,1);
6225
create table t2 (uid int, name varchar(128));
6226
insert into t2 values (1, "A"), (2, "B");
6227
create table t3 (uid int, fid int, index(uid));
6228
insert into t3 values (1,3), (1,3);
6229
create table t4 (uid int);
6230
insert into t4 values (3);
6231
explain select t2.uid from t2, t1
6232
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
6234
id select_type table type possible_keys key key_len ref rows Extra
6235
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
6236
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
6237
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
6238
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 NULL
6239
2 MATERIALIZED t3 ref uid uid 5 const 1 Using where; Using join buffer (Batched Key Access (unique))
6240
select t2.uid from t2, t1
6241
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
6245
drop table t1,t2,t3,t4;
6254
INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
6255
CREATE TABLE t2 LIKE t1;
6256
INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
6257
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
6258
id select_type table type possible_keys key key_len ref rows Extra
6259
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
6260
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6261
SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
6264
SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
6268
CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
6269
INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
6270
INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
6271
INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
6272
CREATE TABLE t2 LIKE t1;
6273
INSERT INTO t2 VALUES (1, 1.789);
6274
INSERT INTO t2 VALUES (13, 1.454);
6275
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
6276
id select_type table type possible_keys key key_len ref rows Extra
6277
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
6278
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop)
6279
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
6280
SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
6285
ID int(11) NOT NULL auto_increment,
6286
Name char(35) NOT NULL default '',
6287
Country char(3) NOT NULL default '',
6288
Population int(11) NOT NULL default '0',
6294
Code char(3) NOT NULL default '',
6295
Name char(52) NOT NULL default '',
6296
SurfaceArea float(10,2) NOT NULL default '0.00',
6297
Population int(11) NOT NULL default '0',
6298
Capital int(11) default NULL,
6300
UNIQUE INDEX (Name),
6304
Country char(3) NOT NULL default '',
6305
Language char(30) NOT NULL default '',
6306
Percentage float(3,1) NOT NULL default '0.0',
6307
PRIMARY KEY (Country, Language),
6310
EXPLAIN SELECT Name FROM t2
6311
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
6313
t2.Code IN (SELECT Country FROM t3
6314
WHERE Language='English' AND Percentage > 10 AND
6315
t2.Population > 100000);
6316
id select_type table type possible_keys key key_len ref rows Extra
6317
1 SIMPLE t1 range Population,Country Population 4 NULL 1 Using index condition; Using MRR; Start temporary
6318
1 SIMPLE t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary; Using join buffer (Batched Key Access (unique))
6319
1 SIMPLE t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (Batched Key Access (unique))
6320
EXPLAIN FORMAT=JSON SELECT Name FROM t2
6321
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
6323
t2.Code IN (SELECT Country FROM t3
6324
WHERE Language='English' AND Percentage > 10 AND
6325
t2.Population > 100000);
6332
"duplicates_removal": {
6333
"using_temporary_table": true,
6338
"access_type": "range",
6343
"key": "Population",
6350
"index_condition": "(`test`.`t1`.`Population` > 5000000)",
6357
"access_type": "eq_ref",
6372
"using_join_buffer": "Batched Key Access (unique)",
6373
"attached_condition": "(`test`.`t2`.`Population` > 100000)"
6382
"access_type": "eq_ref",
6399
"index_condition": "(`test`.`t3`.`Language` = 'English')",
6400
"using_join_buffer": "Batched Key Access (unique)",
6401
"attached_condition": "(`test`.`t3`.`Percentage` > 10)"
6408
Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1
6409
Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` semi join (`test`.`t1`) join `test`.`t2` where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000))
6410
DROP TABLE t1,t2,t3;
6412
Code char(3) NOT NULL DEFAULT '',
6413
Name char(52) NOT NULL DEFAULT '',
6414
Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
6415
Region char(26) NOT NULL DEFAULT '',
6416
SurfaceArea float(10,2) NOT NULL DEFAULT '0.00',
6417
IndepYear smallint(6) DEFAULT NULL,
6418
Population int(11) NOT NULL DEFAULT '0',
6419
LifeExpectancy float(3,1) DEFAULT NULL,
6420
GNP float(10,2) DEFAULT NULL,
6421
GNPOld float(10,2) DEFAULT NULL,
6422
LocalName char(45) NOT NULL DEFAULT '',
6423
GovernmentForm char(45) NOT NULL DEFAULT '',
6424
HeadOfState char(60) DEFAULT NULL,
6425
Capital int(11) DEFAULT NULL,
6426
Code2 char(2) NOT NULL DEFAULT '',
6430
ID int(11) NOT NULL AUTO_INCREMENT,
6431
Name char(35) NOT NULL DEFAULT '',
6432
CountryCode char(3) NOT NULL DEFAULT '',
6433
District char(20) NOT NULL DEFAULT '',
6434
Population int(11) NOT NULL DEFAULT '0',
6436
KEY CountryCode (CountryCode)
6438
Fill the table with test data
6439
This must not use LooseScan:
6440
EXPLAIN SELECT Name FROM t1
6442
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
6443
id select_type table type possible_keys key key_len ref rows Extra
6444
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 31 Using where
6445
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.Code 1 NULL
6446
2 MATERIALIZED t2 ALL CountryCode NULL NULL NULL 545 Using where
6449
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
6456
create table t0 (a int);
6457
insert into t0 values (0),(1),(2),(3),(4);
6458
create table t1 (a int, b int, key(a));
6459
insert into t1 select a,a from t0;
6460
create table t2 (a int, b int, primary key(a));
6461
insert into t2 select * from t1;
6462
Table t2, unlike table t1, should be displayed as pulled out
6463
explain extended select * from t0
6464
where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
6466
id select_type table type possible_keys key key_len ref rows filtered Extra
6467
1 SIMPLE t0 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary
6468
1 SIMPLE t1 ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access (unique))
6469
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary; Using join buffer (Batched Key Access (unique))
6471
Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
6472
Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`))
6473
update t1 set a=3, b=11 where a=4;
6474
update t2 set b=11 where a=3;
6475
create temporary table tmp select * from t0 where t0.a in
6476
(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
6477
create temporary table tmp_as_ref (a int);
6478
insert into tmp_as_ref values(0),(1),(2),(3);
6485
drop table t0, t1, t2, tmp, tmp_as_ref;
6487
id int(11) NOT NULL,
6490
id int(11) NOT NULL,
6491
fid int(11) NOT NULL,
6493
insert into t1 values(1);
6494
insert into t2 values(1,7503),(2,1);
6495
explain select count(*)
6497
where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid );
6498
ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery'
6500
create table t1 (a int, b int, key (a), key (b));
6501
insert into t1 values (2,4),(2,4),(2,4);
6504
t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a);
6507
create table t1(a int,b int,key(a),key(b));
6508
insert into t1 values (1,1),(2,2),(3,3);
6510
where t1.a not in (select 1 from t1
6511
where t1.a in (select 1 from t1)
6518
(EMPNUM CHAR(3) NOT NULL,
6523
(PNUM CHAR(3) NOT NULL,
6529
(EMPNUM CHAR(3) NOT NULL,
6530
PNUM CHAR(3) NOT NULL,
6532
INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
6533
INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
6534
INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
6535
INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
6536
INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
6537
INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
6538
INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
6539
INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
6540
INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
6541
INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
6542
INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
6543
INSERT INTO t3 VALUES ('E1','P1',40);
6544
INSERT INTO t3 VALUES ('E1','P2',20);
6545
INSERT INTO t3 VALUES ('E1','P3',80);
6546
INSERT INTO t3 VALUES ('E1','P4',20);
6547
INSERT INTO t3 VALUES ('E1','P5',12);
6548
INSERT INTO t3 VALUES ('E1','P6',12);
6549
INSERT INTO t3 VALUES ('E2','P1',40);
6550
INSERT INTO t3 VALUES ('E2','P2',80);
6551
INSERT INTO t3 VALUES ('E3','P2',20);
6552
INSERT INTO t3 VALUES ('E4','P2',20);
6553
INSERT INTO t3 VALUES ('E4','P4',40);
6554
INSERT INTO t3 VALUES ('E4','P5',80);
6556
EMPNUM EMPNAME GRADE CITY
6562
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
6571
WHERE PTYPE = 'Design'));
6576
DROP INDEX t1_IDX ON t1;
6577
CREATE INDEX t1_IDX ON t1(EMPNUM);
6586
WHERE PTYPE = 'Design'));
6591
DROP INDEX t1_IDX ON t1;
6600
WHERE PTYPE = 'Design'));
6605
DROP TABLE t1, t2, t3;
6606
CREATE TABLE t1 (f1 INT NOT NULL);
6607
CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1;
6612
create table t0 (a int);
6613
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
6614
create table t1(a int, b int);
6615
insert into t1 values (0,0),(1,1),(2,2);
6616
create table t2 as select * from t1;
6617
create table t3 (pk int, a int, primary key(pk));
6618
insert into t3 select a,a from t0;
6620
select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3));
6621
id select_type table type possible_keys key key_len ref rows Extra
6622
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL
6623
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
6624
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using index
6625
drop table t0, t1, t2, t3;
6626
create table t0 (a int);
6627
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
6628
create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C;
6629
create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1;
6630
show create table t2;
6632
t2 CREATE TABLE `t2` (
6633
`id` int(11) NOT NULL DEFAULT '0',
6634
`a` int(11) DEFAULT NULL,
6637
) ENGINE=MyISAM DEFAULT CHARSET=latin1
6639
create table t3 as select * from t2 limit 0;
6640
insert into t3 select @a:=@a+1, t2.a from t2, t0;
6641
insert into t3 select @a:=@a+1, t2.a from t2, t0;
6642
insert into t3 select @a:=@a+1, t2.a from t2, t0;
6643
alter table t3 add primary key(id), add key(a);
6644
The following must use loose index scan over t3, key a:
6645
explain select count(a) from t2 where a in ( SELECT a FROM t3);
6646
id select_type table type possible_keys key key_len ref rows Extra
6647
1 SIMPLE t2 index a a 5 NULL 1000 Using where; Using index
6648
1 SIMPLE t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
6649
select count(a) from t2 where a in ( SELECT a FROM t3);
6652
drop table t0,t1,t2,t3;
6654
# Bug#33062: subquery in stored routine cause crash
6656
CREATE TABLE t1(a INT);
6657
CREATE TABLE t2(c INT);
6658
CREATE PROCEDURE p1(v1 int)
6660
SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2);
6663
CREATE PROCEDURE p2(v1 int)
6665
SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2);
6668
CREATE PROCEDURE p3(v1 int)
6672
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
6673
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
6674
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
6675
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
6676
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
6677
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
6678
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
6679
t1 t57,t1 t58,t1 t59,t1 t60
6680
WHERE t01.a IN (SELECT c FROM t2);
6683
CREATE PROCEDURE p4(v1 int)
6687
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
6688
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
6689
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
6690
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
6691
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
6692
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
6693
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
6694
t1 t57,t1 t58,t1 t59,t1 t60
6695
WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2);
6712
# Bug#48213 Materialized subselect crashes if using GEOMETRY type
6729
INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'));
6730
CREATE TABLE t2 LIKE t1;
6731
INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'));
6732
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
6733
id select_type table type possible_keys key key_len ref rows filtered Extra
6734
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6735
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6737
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
6738
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
6741
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0);
6742
id select_type table type possible_keys key key_len ref rows filtered Extra
6743
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6744
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6746
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6747
SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0);
6751
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0);
6752
id select_type table type possible_keys key key_len ref rows filtered Extra
6753
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6754
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6756
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6757
SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0);
6760
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0);
6761
id select_type table type possible_keys key key_len ref rows filtered Extra
6762
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6763
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6765
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6766
SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0);
6770
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0);
6771
id select_type table type possible_keys key key_len ref rows filtered Extra
6772
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6773
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6775
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6776
SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0);
6780
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0);
6781
id select_type table type possible_keys key key_len ref rows filtered Extra
6782
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6783
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6785
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6786
SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0);
6790
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0);
6791
id select_type table type possible_keys key key_len ref rows filtered Extra
6792
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6793
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6795
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6796
SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0);
6800
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0);
6801
id select_type table type possible_keys key key_len ref rows filtered Extra
6802
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6803
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6805
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6806
SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0);
6810
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0);
6811
id select_type table type possible_keys key key_len ref rows filtered Extra
6812
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6813
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6815
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6816
SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0);
6820
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0);
6821
id select_type table type possible_keys key key_len ref rows filtered Extra
6822
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL
6823
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop)
6825
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0))
6826
SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0);
6833
# BUG#53060: LooseScan semijoin strategy does not return all rows
6835
CREATE TABLE t1 (i INTEGER);
6836
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
6837
CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j));
6838
INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
6840
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
6841
id select_type table type possible_keys key key_len ref rows Extra
6842
1 SIMPLE t2 index k k 10 NULL 4 Using where; Using index; LooseScan
6843
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (Block Nested Loop)
6844
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
6851
# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows"
6853
create table t1 (uid int, fid int, index(uid));
6854
insert into t1 values
6855
(1,1), (1,2), (1,3), (1,4),
6856
(2,5), (2,6), (2,7), (2,8),
6857
(3,1), (3,2), (3,9);
6858
create table t2 (uid int primary key, name varchar(128), index(name));
6859
insert into t2 values
6860
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
6861
(6, "F"), (7, "G"), (8, "H"), (9, "I");
6862
create table t3 (uid int, fid int, index(uid));
6863
insert into t3 values
6864
(1,1), (1,2), (1,3),(1,4),
6865
(2,5), (2,6), (2,7), (2,8),
6866
(3,1), (3,2), (3,9);
6867
create table t4 (uid int primary key, name varchar(128), index(name));
6868
insert into t4 values
6869
(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"),
6870
(6, "F"), (7, "G"), (8, "H"), (9, "I");
6871
explain select name from t2, t1
6872
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
6874
id select_type table type possible_keys key key_len ref rows Extra
6875
1 SIMPLE t3 ref uid uid 5 const 4 Using where; Start temporary
6876
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index
6877
1 SIMPLE t1 ref uid uid 5 test.t3.fid 2 End temporary; Using join buffer (Batched Key Access (unique))
6878
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 9 Using where; Using join buffer (Block Nested Loop)
6879
select name from t2, t1
6880
where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
6894
drop table t1,t2,t3,t4;
6896
# Bug#43768 Prepared query with nested subqueries core dump on second execution
6900
partner_id VARCHAR(35)
6902
INSERT INTO t1 VALUES
6903
(1, 'partner1'), (2, 'partner2'),
6904
(3, 'partner3'), (4, 'partner4');
6908
article_id VARCHAR(20),
6909
PRIMARY KEY(id, t1_line_id)
6911
INSERT INTO t2 VALUES
6912
(1, 1, 'sup'), (2, 1, 'sup'),
6913
(2, 2, 'sup'), (2, 3, 'sup'),
6914
(2, 4, 'imp'), (3, 1, 'sup'),
6917
user_id VARCHAR(50),
6918
article_id VARCHAR(20) NOT NULL,
6919
PRIMARY KEY(user_id)
6921
INSERT INTO t3 VALUES('nicke', 'imp');
6923
SELECT t1.partner_id
6928
WHERE article_id IN (
6929
SELECT article_id FROM t3
6930
WHERE user_id = 'nicke'
6933
id select_type table type possible_keys key key_len ref rows Extra
6934
1 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL
6935
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL
6936
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access (unique))
6937
SELECT t1.partner_id
6942
WHERE article_id IN (
6943
SELECT article_id FROM t3
6944
WHERE user_id = 'nicke'
6950
'EXPLAIN SELECT t1.partner_id
6955
WHERE article_id IN (
6956
SELECT article_id FROM t3
6957
WHERE user_id = \'nicke\'
6961
id select_type table type possible_keys key key_len ref rows Extra
6962
1 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL
6963
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL
6964
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access (unique))
6966
id select_type table type possible_keys key key_len ref rows Extra
6967
1 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL
6968
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL
6969
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access (unique))
6971
'SELECT t1.partner_id
6976
WHERE article_id IN (
6977
SELECT article_id FROM t3
6978
WHERE user_id = \'nicke\'
6987
DROP TABLE t1,t2,t3;
6990
# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result
6992
CREATE TABLE t1 (i INTEGER);
6993
CREATE TABLE t2 (i INTEGER);
6994
CREATE TABLE t3 (i INTEGER);
6995
INSERT INTO t1 VALUES (1), (2);
6996
INSERT INTO t2 VALUES (6);
6997
INSERT INTO t3 VALUES (1), (2);
6998
explain extended SELECT * FROM t1 WHERE (t1.i) IN
6999
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
7000
id select_type table type possible_keys key key_len ref rows filtered Extra
7001
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL 0.00 NULL
7002
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop)
7003
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 NULL
7004
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop)
7006
Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `<subquery2>`.`i`)
7007
SELECT * FROM t1 WHERE (t1.i) IN
7008
(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
7012
drop table t1,t2,t3;
7014
# BUG#49453: re-execution of prepared statement with view
7015
# and semijoin crashes
7017
CREATE TABLE t1 (city VARCHAR(50), country_id INT);
7018
CREATE TABLE t2 (country_id INT, country VARCHAR(50));
7019
INSERT INTO t1 VALUES
7020
('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ;
7021
INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa');
7023
SELECT country_id as vf_country_id
7025
WHERE LEFT(country,1) = "A";
7027
SELECT city, country_id
7029
WHERE country_id IN (SELECT vf_country_id FROM v1);
7047
# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch
7048
# and duplicates weedout)
7050
create table t1 (a int);
7051
create table t2 (a int);
7052
create table t3 (a int);
7053
insert into t1 values(1),(1);
7054
insert into t2 values(1),(1),(1),(1);
7055
insert into t3 values(2),(2);
7056
explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
7057
id select_type table type possible_keys key key_len ref rows Extra
7058
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
7059
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.a 1 NULL
7060
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 NULL
7061
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
7062
select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a);
7066
drop table t1,t2,t3;
7068
# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN))
7070
CREATE TABLE t1 (a INT);
7071
CREATE TABLE t2 (a INT);
7072
CREATE TABLE t3 (a INT);
7073
INSERT INTO t1 VALUES(1),(1);
7074
INSERT INTO t2 VALUES(1),(1);
7075
INSERT INTO t3 VALUES(2),(2);
7076
explain SELECT * FROM t1
7077
WHERE t1.a IN (SELECT t2.a
7078
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
7079
id select_type table type possible_keys key key_len ref rows Extra
7080
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
7081
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.a 1 NULL
7082
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL
7083
2 MATERIALIZED t2inner ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
7084
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
7086
WHERE t1.a IN (SELECT t2.a
7087
FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a);
7091
DROP TABLE t1,t2,t3;
7093
# BUG#52329 - Wrong result: subquery materialization, IN,
7094
# non-null field followed by nullable
7096
CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL);
7097
CREATE TABLE t2a (b1 char(8), b2 char(8));
7098
CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL);
7099
CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8));
7100
INSERT INTO t1 VALUES ('1 - 12', '2 - 22');
7101
INSERT INTO t2a VALUES ('1 - 11', '2 - 21'),
7102
('1 - 11', '2 - 21'),
7103
('1 - 12', '2 - 22'),
7104
('1 - 12', '2 - 22'),
7105
('1 - 13', '2 - 23');
7106
INSERT INTO t2b SELECT * FROM t2a;
7107
INSERT INTO t2c SELECT * FROM t2a;
7110
SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2);
7115
SELECT b1, b2 FROM t2a WHERE b1 > '0');
7120
SELECT b1, b2 FROM t2b WHERE b1 > '0');
7125
SELECT b1, b2 FROM t2c WHERE b1 > '0');
7128
DROP TABLE t1,t2a,t2b,t2c;
7131
# Bug#45174: Incorrectly applied equality propagation caused wrong
7132
# result on a query with a materialized semi-join.
7135
varchar_nokey varchar(1) NOT NULL
7137
INSERT INTO t1 VALUES
7138
('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'),
7139
('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u');
7142
varchar_key varchar(1) NOT NULL,
7143
varchar_nokey varchar(1) NOT NULL,
7145
KEY varchar_key(varchar_key)
7147
INSERT INTO t2 VALUES
7148
(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''),
7149
(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'),
7150
(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p');
7151
SELECT varchar_nokey
7153
WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey
7155
WHERE varchar_nokey < 'n' XOR pk);
7157
explain SELECT varchar_nokey
7159
WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey
7161
WHERE varchar_nokey < 'n' XOR pk);
7162
id select_type table type possible_keys key key_len ref rows Extra
7163
1 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where
7164
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 6 test.t1.varchar_nokey,test.t1.varchar_nokey 1 NULL
7165
2 MATERIALIZED t2 ALL varchar_key NULL NULL NULL 15 Using where
7167
# End of the test for bug#45174.
7169
# Bug#50019: Wrong result for IN-query with materialization
7171
CREATE TABLE t1(i INT);
7172
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
7173
CREATE TABLE t2(i INT);
7174
INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
7175
CREATE TABLE t3(i INT);
7176
INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
7177
SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i
7179
WHERE t2.i + t3.i = 5);
7185
explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i
7187
WHERE t2.i + t3.i = 5);
7188
id select_type table type possible_keys key key_len ref rows Extra
7189
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
7190
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL
7191
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL
7192
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop)
7193
DROP TABLE t1,t2,t3;
7194
# End of the test for bug#50019.
7196
# Bug#52068: Optimizer generates invalid semijoin materialization plan
7198
CREATE TABLE ot1(a INTEGER);
7199
INSERT INTO ot1 VALUES(5), (8);
7200
CREATE TABLE it2(a INTEGER);
7201
INSERT INTO it2 VALUES(9), (5), (1), (8);
7202
CREATE TABLE it3(a INTEGER);
7203
INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4);
7204
CREATE TABLE ot4(a INTEGER);
7205
INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1);
7206
SELECT * FROM ot1,ot4
7207
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
7220
explain SELECT * FROM ot1,ot4
7221
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
7223
id select_type table type possible_keys key key_len ref rows Extra
7224
1 SIMPLE ot1 ALL NULL NULL NULL NULL 2 NULL
7225
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where; Using join buffer (Block Nested Loop)
7226
1 SIMPLE ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
7227
2 MATERIALIZED it2 ALL NULL NULL NULL NULL 4 NULL
7228
2 MATERIALIZED it3 ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop)
7229
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
7230
# End of the test for bug#52068.
7232
# Bug#57623: subquery within before insert trigger causes crash (sj=on)
7234
CREATE TABLE ot1(a INT);
7235
CREATE TABLE ot2(a INT);
7236
CREATE TABLE ot3(a INT);
7237
CREATE TABLE it1(a INT);
7238
INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
7239
INSERT INTO ot2 VALUES(0),(2),(4),(6);
7240
INSERT INTO ot3 VALUES(0),(3),(6);
7241
INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);
7245
(ot2 JOIN ot3 on ot2.a=ot3.a)
7246
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
7247
id select_type table type possible_keys key key_len ref rows Extra
7248
1 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL
7249
1 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1)
7250
1 SIMPLE ot3 ALL NULL NULL NULL NULL 3 NULL
7251
1 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where
7255
(ot2 JOIN ot3 on ot2.a=ot3.a)
7256
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1);
7266
prepare s from 'SELECT *
7269
(ot2 JOIN ot3 on ot2.a=ot3.a)
7270
ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)';
7291
deallocate prepare s;
7292
DROP TABLE ot1, ot2, ot3, it1;
7293
# End of the test for bug#57623.
7295
# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on
7297
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
7298
CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM;
7299
INSERT INTO t1 VALUES (1);
7300
INSERT INTO t2 VALUES (1,1), (2,1);
7301
EXPLAIN SELECT * FROM t2
7302
WHERE f2 IN (SELECT t1.f1
7303
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
7304
id select_type table type possible_keys key key_len ref rows Extra
7305
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Start temporary
7306
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
7307
1 SIMPLE b1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
7308
1 SIMPLE b2 ALL NULL NULL NULL NULL 2 End temporary; Using join buffer (Block Nested Loop)
7310
WHERE f2 IN (SELECT t1.f1
7311
FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE);
7316
# End of the test for bug#11766739.
7318
# Bug#11766642: crash in Item_field::register_field_in_read_map with view
7320
CREATE TABLE t1(a INT);
7321
CREATE VIEW v1 AS SELECT a FROM t1;
7322
INSERT INTO t1 VALUES (0),(1),(2);
7323
SELECT a FROM t1 WHERE a IN
7324
(SELECT a XOR a FROM v1)
7331
# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3
7336
INSERT INTO t1 VALUES ('v'),('we');
7338
col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
7342
INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6);
7347
INSERT INTO t3 VALUES (4,4);
7350
WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2
7351
FROM t2 AS a1 LEFT JOIN t3 AS a2
7352
ON a1.col_int_key = a2.col_int_key
7353
WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL);
7357
DROP TABLE t1,t2,t3;
7359
# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT
7360
# OF ROWS WHEN JCL>=3
7362
CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1));
7363
INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u');
7364
CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1));
7365
INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u');
7366
CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1));
7367
INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v');
7368
SELECT table2.col_int_key
7369
from t3 as table1 join t1 as table2 on table2.col_int_nokey
7370
where table1.col_int_nokey in
7372
select subquery2_t2.col_int_nokey
7373
from t3 as subquery2_t1
7376
join t1 as subquery2_t3
7377
on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey
7378
on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey
7379
where subquery2_t1.col_varchar_key != table1.col_varchar_key
7380
or subquery2_t2.pk <= table1.pk
7385
DROP TABLE t1,t2,t3;
7387
# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
7389
CREATE TABLE t1 (i1 int);
7390
INSERT INTO t1 VALUES (1);
7391
CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
7392
INSERT INTO t2 VALUES (1, 2),(7, 3);
7393
SELECT GRANDPARENT1.i1
7394
FROM t2 AS GRANDPARENT1
7395
WHERE GRANDPARENT1.i2
7396
IN ( SELECT PARENT1.i2
7397
FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
7399
GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
7400
ORDER BY PARENT1.i1)
7401
ORDER BY GRANDPARENT1.i2 ;
7406
# Bug#12640083: Same query executed as WHERE subquery gives different
7407
# results on IN() compare
7411
col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
7412
col_varchar_10_latin1_key varchar(10) DEFAULT NULL,
7414
KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)),
7415
KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key)
7417
INSERT INTO t1 VALUES
7421
(4, 'abcd', 'abcd');
7423
pk int NOT NULL AUTO_INCREMENT,
7427
SELECT alias1.col_varchar_10_latin1_key
7429
LEFT JOIN t1 AS alias2
7431
ON alias2.col_varchar_10_latin1_key
7432
ON alias1.col_varchar_1024_utf8_key
7433
WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk;
7436
WHERE col_varchar_10_latin1_key IN (
7437
SELECT alias1.col_varchar_10_latin1_key
7439
LEFT JOIN t1 AS alias2
7441
ON alias2.col_varchar_10_latin1_key
7442
ON alias1.col_varchar_1024_utf8_key
7443
WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk);
7444
id select_type table type possible_keys key key_len ref rows Extra
7445
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
7446
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 13 test.t3.col_varchar_10_latin1_key 1 NULL
7447
2 MATERIALIZED alias1 ALL NULL NULL NULL NULL 4 Using where
7448
2 MATERIALIZED alias3 index NULL PRIMARY 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop)
7449
2 MATERIALIZED alias2 index NULL col_varchar_10_latin1_key 13 NULL 4 Using where; Using index; Using join buffer (Block Nested Loop)
7452
WHERE col_varchar_10_latin1_key IN (
7453
SELECT alias1.col_varchar_10_latin1_key
7455
LEFT JOIN t1 AS alias2
7457
ON alias2.col_varchar_10_latin1_key
7458
ON alias1.col_varchar_1024_utf8_key
7459
WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk);
7460
col_varchar_10_latin1_key
7463
DROP TABLE t1, t2, t3;
7464
# End of the test for bug#12640083.
7466
# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output
7470
col_int_key int NOT NULL,
7471
col_varchar_nokey varchar(1) NOT NULL,
7472
col_varchar_key varchar(1) NOT NULL,
7474
KEY col_int_key(col_int_key),
7475
KEY col_varchar_key(col_varchar_key, col_int_key)
7477
INSERT INTO t1 VALUES
7496
col_int_key int NOT NULL,
7497
col_varchar_key varchar(1) NOT NULL,
7499
KEY col_varchar_key(col_varchar_key, col_int_key)
7501
INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES
7522
EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y
7524
WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key
7526
WHERE innr.col_varchar_key = 'a' OR innr.pk = 8)
7527
AND outr.col_varchar_nokey < 't'
7528
ORDER BY outr.col_varchar_key, outr.pk;
7529
id select_type table type possible_keys key key_len ref rows Extra
7530
1 SIMPLE innr index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 3,4 NULL 2 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary
7531
1 SIMPLE outr ref col_varchar_key col_varchar_key 3 test.innr.col_varchar_key 1 Using where; End temporary; Using join buffer (Batched Key Access (unique))
7532
SELECT outr.col_varchar_key AS x, outr.pk AS y
7534
WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key
7536
WHERE innr.col_varchar_key = 'a' OR innr.pk = 8)
7537
AND outr.col_varchar_nokey < 't'
7538
ORDER BY outr.col_varchar_key, outr.pk;
7545
# End of bug#12603200
7547
# Bug#12603183: Segfault in hp_movelink
7550
col_varchar_key varchar(1) ,
7551
col_varchar_nokey varchar(1) ,
7552
KEY col_varchar_key(col_varchar_key)
7554
INSERT INTO t1 VALUES
7571
col_varchar_nokey varchar(1)
7573
INSERT INTO t2 VALUES
7575
EXPLAIN SELECT grandparent1.col_varchar_nokey
7576
FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey)
7577
WHERE (grandparent1.col_varchar_key) IN
7578
(SELECT parent1.col_varchar_nokey
7580
WHERE parent1.col_varchar_key IN
7581
(SELECT child1.col_varchar_nokey AS c1
7582
FROM t1 AS child1 LEFT JOIN t2 AS child2
7583
ON (child1.col_varchar_key > child2.col_varchar_nokey)));
7584
id select_type table type possible_keys key key_len ref rows Extra
7585
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where
7586
1 SIMPLE grandparent1 ref col_varchar_key col_varchar_key 4 <subquery2>.col_varchar_nokey 2 Using join buffer (Batched Key Access (unique))
7587
1 SIMPLE grandparent2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
7588
2 MATERIALIZED child1 ALL NULL NULL NULL NULL 15 Using where
7589
2 MATERIALIZED child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
7590
2 MATERIALIZED parent1 ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 Using join buffer (Batched Key Access (unique))
7591
SELECT grandparent1.col_varchar_nokey
7592
FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey)
7593
WHERE (grandparent1.col_varchar_key) IN
7594
(SELECT parent1.col_varchar_nokey
7596
WHERE parent1.col_varchar_key IN
7597
(SELECT child1.col_varchar_nokey AS c1
7598
FROM t1 AS child1 LEFT JOIN t2 AS child2
7599
ON (child1.col_varchar_key > child2.col_varchar_nokey)));
7617
# End of test for bug#12603183.
7619
# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery
7622
col_int_key INT NOT NULL,
7623
col_datetime_key DATETIME NOT NULL,
7624
col_varchar_key VARCHAR(1) NOT NULL,
7625
KEY col_int_key (col_int_key),
7626
KEY col_datetime_key(col_datetime_key),
7627
KEY col_varchar_key (col_varchar_key,col_int_key)
7629
INSERT INTO t1 VALUES
7630
(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'),
7631
(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'),
7632
(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'),
7633
(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'),
7634
(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'),
7635
(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'),
7636
(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'),
7637
(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'),
7638
(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'),
7639
(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w');
7641
col_varchar_nokey VARCHAR(1) NOT NULL
7643
INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r');
7644
explain SELECT col_varchar_key
7646
WHERE col_varchar_key IN (SELECT col_varchar_nokey
7648
ORDER BY col_datetime_key LIMIT 4;
7649
id select_type table type possible_keys key key_len ref rows Extra
7650
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort; Start temporary
7651
1 SIMPLE t1 ref col_varchar_key col_varchar_key 3 test.t2.col_varchar_nokey 1 End temporary; Using join buffer (Batched Key Access (unique))
7652
SELECT col_varchar_key
7654
WHERE col_varchar_key IN (SELECT col_varchar_nokey
7656
ORDER BY col_datetime_key LIMIT 4;
7663
# End of test for bug#12818569.
7665
# Bug#12803439: Assert in replace_subcondition() on update query
7667
CREATE TABLE t1(a INTEGER);
7668
INSERT INTO t1 values(1), (2);
7669
CREATE TABLE t2(a INTEGER);
7670
INSERT INTO t2 VALUES(1), (3);
7673
WHERE a IN (SELECT a
7675
HAVING a IN (SELECT a
7678
HAVING a IN (SELECT a
7683
# End of test for bug#12803439.
7685
# Bug#12797534: Segfault in hp_movelink still exists
7688
g1 VARCHAR(1) NOT NULL
7690
INSERT INTO t1 VALUES ('d'), ('s');
7693
col_int_key INT NOT NULL,
7694
col_varchar_key VARCHAR(1) NOT NULL,
7695
col_varchar_nokey VARCHAR(1) NOT NULL,
7697
KEY col_varchar_key(col_varchar_key, col_int_key)
7699
INSERT INTO t2 VALUES
7700
(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'),
7701
(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'),
7702
(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'),
7703
(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'),
7704
(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e');
7706
pk INTEGER NOT NULL,
7709
INSERT INTO t3 VALUES (10);
7713
(SELECT grandparent1.col_varchar_nokey AS g1
7714
FROM t2 AS grandparent1
7715
WHERE grandparent1.col_varchar_key IN
7716
(SELECT parent1.col_varchar_nokey AS p1
7717
FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk)
7719
AND grandparent1.col_varchar_key IS NOT NULL
7721
id select_type table type possible_keys key key_len ref rows Extra
7722
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
7723
2 SUBQUERY parent1 ALL NULL NULL NULL NULL 20 Start temporary
7724
2 SUBQUERY parent2 eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 Using index
7725
2 SUBQUERY grandparent1 ref col_varchar_key col_varchar_key 3 test.parent1.col_varchar_nokey 1 Using index condition; End temporary; Using join buffer (Batched Key Access (unique))
7729
(SELECT grandparent1.col_varchar_nokey AS g1
7730
FROM t2 AS grandparent1
7731
WHERE grandparent1.col_varchar_key IN
7732
(SELECT parent1.col_varchar_nokey AS p1
7733
FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk)
7735
AND grandparent1.col_varchar_key IS NOT NULL
7738
DROP TABLE t1, t2, t3;
7740
pk INTEGER AUTO_INCREMENT,
7741
col_int_key INTEGER ,
7742
col_varchar_key VARCHAR(1) ,
7743
col_varchar_nokey VARCHAR(1) ,
7745
KEY (col_varchar_key,col_int_key)
7747
INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES
7748
(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r');
7750
pk INTEGER AUTO_INCREMENT,
7751
col_int_key INTEGER ,
7752
col_varchar_key VARCHAR(1) ,
7753
col_varchar_nokey VARCHAR(1) ,
7756
KEY (col_varchar_key,col_int_key)
7757
) AUTO_INCREMENT=10 ENGINE=INNODB;
7758
INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES
7759
(NULL,'x','x'), (NULL,'j','j'), (8,'c','c');
7761
SELECT outr.col_varchar_nokey AS x
7763
WHERE outr.col_varchar_nokey IN
7764
(SELECT innr.col_varchar_nokey AS y
7766
WHERE innr.col_int_key IS NULL)
7767
AND outr.col_varchar_nokey IS NOT NULL
7768
AND NOT col_varchar_key IS NULL;
7772
(SELECT outr.col_varchar_nokey AS x
7774
WHERE outr.col_varchar_nokey IN
7775
(SELECT innr.col_varchar_nokey AS y
7777
WHERE innr.col_int_key IS NULL)
7778
AND outr.col_varchar_nokey IS NOT NULL
7779
AND NOT col_varchar_key IS NULL);
7781
DROP TABLE t1, t2, t3;
7782
# End of test for bug#12797534.
7784
# Bug#12714094: Assert in optimize_semijoin_nests()
7788
col_varchar VARCHAR(10) DEFAULT NULL,
7791
INSERT INTO it VALUES (1, 'g');
7793
SELECT alias1.pk AS field1
7795
LEFT JOIN it AS alias2
7796
ON alias1.col_varchar = alias2.col_varchar
7803
LEFT JOIN it AS alias2
7804
ON alias1.col_varchar = alias2.col_varchar
7809
# End of test for bug#12714094
7811
# Bug#12867557: Valgrind: conditional jump/move at key_cmp
7814
pk INTEGER AUTO_INCREMENT,
7815
col_int_key INTEGER,
7818
) AUTO_INCREMENT=10;
7819
INSERT INTO t1 (col_int_key) VALUES (8);
7821
pk INTEGER AUTO_INCREMENT,
7822
col_int_key INTEGER,
7827
) AUTO_INCREMENT=10;
7828
INSERT INTO t2 (col_int_key, col_time_key)
7830
(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
7831
(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
7832
(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
7833
(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
7834
(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
7835
(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
7836
(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
7838
SELECT DISTINCT grandparent1.col_time_key AS g1
7839
FROM t2 AS grandparent1
7840
WHERE grandparent1.col_int_key IN
7841
(SELECT parent1.col_int_key AS p1
7843
AND grandparent1.pk > 9;
7847
(SELECT grandparent1.col_time_key AS g1
7848
FROM t2 AS grandparent1
7849
WHERE grandparent1.col_int_key IN
7850
(SELECT parent1.col_int_key AS p1
7852
AND grandparent1.pk > 9);
7853
DROP TABLE t0, t1, t2;
7854
# End of test for bug#12867557
7856
# Bug#12711441: crash in fix_after_pullout
7860
col_int_nokey int DEFAULT NULL,
7861
col_int_key int DEFAULT NULL,
7862
col_time_key time DEFAULT NULL,
7863
col_varchar_key varchar(1) DEFAULT NULL,
7866
CREATE VIEW v1 AS SELECT * FROM t1;
7868
col_int_key int DEFAULT NULL,
7869
col_varchar_key varchar(1) DEFAULT NULL,
7870
col_varchar_nokey varchar(1) DEFAULT NULL,
7871
KEY col_varchar_key(col_varchar_key, col_int_key)
7875
col_int_key INT DEFAULT NULL,
7879
col_int_nokey INT DEFAULT NULL,
7880
col_varchar_key varchar(1) DEFAULT NULL,
7881
col_varchar_nokey varchar(1) DEFAULT NULL,
7882
KEY col_varchar_key(col_varchar_key)
7885
SELECT alias1.col_time_key AS field1
7887
RIGHT JOIN t3 AS alias2
7888
ON alias2.col_int_key = alias1.col_int_nokey
7889
WHERE alias1.pk >= SOME(
7890
SELECT SQ1_alias1.pk AS SQ1_field1
7891
FROM t3 AS SQ1_alias1
7892
INNER JOIN (t2 AS SQ1_alias2
7893
INNER JOIN t4 AS SQ1_alias3
7894
ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
7895
ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
7896
WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
7897
AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
7899
SELECT * FROM ts WHERE field1 IN (
7900
SELECT alias1.col_time_key AS field1
7902
RIGHT JOIN t3 AS alias2
7903
ON alias2.col_int_key = alias1.col_int_nokey
7904
WHERE alias1.pk >= SOME(
7905
SELECT SQ1_alias1.pk AS SQ1_field1
7906
FROM t3 AS SQ1_alias1
7907
INNER JOIN (t2 AS SQ1_alias2
7908
INNER JOIN t4 AS SQ1_alias3
7909
ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
7910
ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
7911
WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
7912
AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
7915
DROP TABLE t1, t2, t3, t4, ts;
7917
# End of test for bug#12711441.
7919
# Bug#12664936: Same query executed as where subquery ...
7922
col_varchar_key VARCHAR(1),
7923
KEY col_varchar_key (col_varchar_key)
7925
INSERT INTO t1 VALUES
7926
('o'), ('w'), ('m'), ('q'),
7927
('f'), ('p'), ('j'), ('c');
7929
col_int_nokey INTEGER,
7930
col_int_key INTEGER,
7931
col_varchar_key varchar(1),
7932
KEY col_int_key (col_int_key)
7934
INSERT INTO t2 VALUES
7935
(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'),
7936
(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n');
7938
SELECT t2.col_int_nokey, t2.col_varchar_key
7939
FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key
7940
WHERE t2.col_int_key = 1;
7943
WHERE (col_int_nokey, col_varchar_key) IN
7944
(SELECT t2.col_int_nokey, t2.col_varchar_key
7945
FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key
7946
WHERE t2.col_int_key = 1
7948
id select_type table type possible_keys key key_len ref rows Extra
7949
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where
7950
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 9 test.t4.col_int_nokey,test.t4.col_varchar_key 1 NULL
7951
2 MATERIALIZED t2 ref col_int_key col_int_key 5 const 3 Using where
7952
2 MATERIALIZED t1 ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 Using index
7955
WHERE (col_int_nokey, col_varchar_key) IN
7956
(SELECT t2.col_int_nokey, t2.col_varchar_key
7957
FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key
7958
WHERE t2.col_int_key = 1
7960
col_int_nokey col_varchar_key
7963
DROP TABLE t1, t2, t4;
7964
# End of test for bug#12664936.
7966
# Bug#13340270: assertion table->sort.record_pointers == __null
7970
col_int_key int DEFAULT NULL,
7971
col_varchar_key varchar(1) DEFAULT NULL,
7972
col_varchar_nokey varchar(1) DEFAULT NULL,
7974
KEY col_int_key (col_int_key),
7975
KEY col_varchar_key (col_varchar_key, col_int_key)
7977
INSERT INTO t1 VALUES
7991
SELECT alias1.col_varchar_nokey AS field1
7992
FROM t1 AS alias1 JOIN t1 AS alias2
7993
ON alias2.col_int_key = alias1.pk OR
7994
alias2.col_int_key = alias1.col_int_key
7995
WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
8000
WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1
8001
FROM t1 AS alias1 JOIN t1 AS alias2
8002
ON alias2.col_int_key = alias1.pk OR
8003
alias2.col_int_key = alias1.col_int_key
8004
WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
8006
id select_type table type possible_keys key key_len ref rows Extra
8007
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
8008
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 4 test.t2.field1 1 NULL
8009
2 MATERIALIZED alias1 index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 4,4 NULL 2 Using sort_union(col_varchar_key,PRIMARY); Using where
8010
2 MATERIALIZED alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2)
8013
WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1
8014
FROM t1 AS alias1 JOIN t1 AS alias2
8015
ON alias2.col_int_key = alias1.pk OR
8016
alias2.col_int_key = alias1.col_int_key
8017
WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
8023
# End of test for bug#13340270.
8025
# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy
8027
CREATE TABLE ot1(a INTEGER);
8028
INSERT INTO ot1 VALUES(1), (2), (3);
8029
CREATE TABLE ot2(a INTEGER);
8030
INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10);
8031
CREATE TABLE it1(a INTEGER);
8032
INSERT INTO it1 VALUES(1), (3), (5), (7);
8033
CREATE TABLE it2(a INTEGER);
8034
INSERT INTO it2 VALUES(1), (3), (5), (7), (9);
8035
explain SELECT ot1.a, ot2.a
8037
WHERE ot1.a IN (SELECT a FROM it1) AND
8038
ot2.a IN (SELECT a FROM it2);
8039
id select_type table type possible_keys key key_len ref rows Extra
8040
1 SIMPLE ot1 ALL NULL NULL NULL NULL 3 NULL
8041
1 SIMPLE it1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot1); Using join buffer (Block Nested Loop)
8042
1 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using join buffer (Block Nested Loop)
8043
1 SIMPLE ot2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (Block Nested Loop)
8044
3 MATERIALIZED it2 ALL NULL NULL NULL NULL 5 NULL
8047
WHERE ot1.a IN (SELECT a FROM it1) AND
8048
ot2.a IN (SELECT a FROM it2);
8052
DROP TABLE ot1, ot2, it1, it2;
8053
# End of test for bug#13335319.
8055
# Bug#13334882: Assertion keypart_map failed in MyIsam function
8059
col_int_nokey INT NOT NULL,
8060
col_int_key INT NOT NULL,
8062
KEY col_int_key (col_int_key)
8064
INSERT INTO t1 VALUES
8078
col_int_nokey int NOT NULL,
8079
col_int_key int NOT NULL,
8081
KEY col_int_key (col_int_key)
8083
INSERT INTO t2 VALUES
8086
SELECT grandparent1.col_int_nokey AS g1
8087
FROM t1 AS grandparent1
8088
WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN
8089
(SELECT parent1.col_int_key AS p1,
8090
parent1.col_int_key AS p2
8092
LEFT JOIN t2 AS parent2
8093
ON parent1.col_int_nokey = parent2.col_int_key
8095
AND grandparent1.col_int_key <> 3
8097
explain SELECT * FROM t3
8099
(SELECT grandparent1.col_int_nokey AS g1
8100
FROM t1 AS grandparent1
8101
WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN
8102
(SELECT parent1.col_int_key AS p1,
8103
parent1.col_int_key AS p2
8105
LEFT JOIN t2 AS parent2
8106
ON parent1.col_int_nokey = parent2.col_int_key
8108
AND grandparent1.col_int_key <> 3
8110
id select_type table type possible_keys key key_len ref rows Extra
8111
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
8112
2 DEPENDENT SUBQUERY grandparent1 ref col_int_key col_int_key 4 func 2 Using index condition; Using where
8113
2 DEPENDENT SUBQUERY <subquery3> eq_ref <auto_key> <auto_key> 8 test.grandparent1.col_int_nokey,test.grandparent1.col_int_nokey 1 NULL
8114
3 MATERIALIZED parent1 ref col_int_key col_int_key 4 func 2 NULL
8115
3 MATERIALIZED parent2 index col_int_key col_int_key 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop)
8116
explain format=json SELECT * FROM t3
8118
(SELECT grandparent1.col_int_nokey AS g1
8119
FROM t1 AS grandparent1
8120
WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN
8121
(SELECT parent1.col_int_key AS p1,
8122
parent1.col_int_key AS p2
8124
LEFT JOIN t2 AS parent2
8125
ON parent1.col_int_nokey = parent2.col_int_key
8127
AND grandparent1.col_int_key <> 3
8134
"message": "Impossible WHERE noticed after reading const tables",
8135
"attached_subqueries": [
8144
"table_name": "grandparent1",
8145
"access_type": "ref",
8149
"key": "col_int_key",
8159
"index_condition": "(`test`.`grandparent1`.`col_int_key` <> 3)",
8160
"attached_condition": "(((`test`.`grandparent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)) and ((`test`.`grandparent1`.`col_int_nokey` is not null) and (`test`.`grandparent1`.`col_int_nokey` is not null)))"
8165
"table_name": "<subquery3>",
8166
"access_type": "eq_ref",
8167
"key": "<auto_key>",
8170
"test.grandparent1.col_int_nokey",
8171
"test.grandparent1.col_int_nokey"
8174
"materialized_from_subquery": {
8175
"using_temporary_table": true,
8180
"table_name": "parent1",
8181
"access_type": "ref",
8185
"key": "col_int_key",
8199
"table_name": "parent2",
8200
"access_type": "index",
8204
"key": "col_int_key",
8211
"using_index": true,
8212
"using_join_buffer": "Block Nested Loop",
8213
"attached_condition": "<if>(is_not_null_compl(parent2), (`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`), true)"
8229
Note 1003 /* select#1 */ select '8' AS `g1` from dual where (not(<in_optimizer>('8',<exists>(/* select#2 */ select 1 from `test`.`t1` `grandparent1` semi join (`test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`))) where ((`test`.`grandparent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery3>`.`p1` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery3>`.`p2` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`))))))
8232
(SELECT grandparent1.col_int_nokey AS g1
8233
FROM t1 AS grandparent1
8234
WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN
8235
(SELECT parent1.col_int_key AS p1,
8236
parent1.col_int_key AS p2
8238
LEFT JOIN t2 AS parent2
8239
ON parent1.col_int_nokey = parent2.col_int_key
8241
AND grandparent1.col_int_key <> 3
8244
DROP TABLE t1, t2, t3;
8245
# End of test for bug#13334882.
8247
# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution
8251
col_varchar_nokey VARCHAR(1)
8253
INSERT INTO t1 VALUES
8256
CREATE TABLE t2 LIKE t1;
8257
INSERT INTO t2 VALUES
8260
CREATE VIEW v_t2 AS SELECT * FROM t2;
8261
CREATE TABLE t3 LIKE t1;
8262
INSERT INTO t3 VALUES
8265
explain SELECT alias1.col_varchar_nokey
8267
INNER JOIN v_t2 AS alias2
8268
ON alias2.col_int_nokey = alias1.col_int_nokey AND
8269
'o' IN (SELECT col_varchar_nokey
8271
id select_type table type possible_keys key key_len ref rows Extra
8272
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch
8273
1 SIMPLE alias1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop)
8274
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
8275
SELECT alias1.col_varchar_nokey
8277
INNER JOIN v_t2 AS alias2
8278
ON alias2.col_int_nokey = alias1.col_int_nokey AND
8279
'o' IN (SELECT col_varchar_nokey
8283
PREPARE stmt FROM "SELECT alias1.col_varchar_nokey
8285
INNER JOIN v_t2 AS alias2
8286
ON alias2.col_int_nokey = alias1.col_int_nokey AND
8287
'o' IN (SELECT col_varchar_nokey
8293
DROP TABLE t1, t2, t3;
8294
# End of test for bug#13339643.
8296
# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses
8300
col_int_nokey int NOT NULL,
8301
col_int_key int NOT NULL,
8303
KEY col_int_key (col_int_key)
8305
INSERT INTO t1 VALUES
8306
(10,1,7), (13,7,3), (18,0,1), (23,8,1);
8309
col_int_key int NOT NULL,
8311
KEY col_int_key (col_int_key)
8313
INSERT INTO t2 VALUES (1,7);
8314
EXPLAIN SELECT t1a.*
8316
JOIN t1 AS t1b USING ( col_int_nokey )
8317
WHERE t1a.col_int_key IN (
8320
WHERE col_int_key IN (
8321
SELECT col_int_nokey
8325
id select_type table type possible_keys key key_len ref rows Extra
8326
1 SIMPLE t2 system PRIMARY,col_int_key NULL NULL NULL 1 NULL
8327
1 SIMPLE t1a ref col_int_key col_int_key 4 const 1 NULL
8328
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1a); Using join buffer (Block Nested Loop)
8329
1 SIMPLE t1b ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
8332
JOIN t1 AS t1b USING ( col_int_nokey )
8333
WHERE t1a.col_int_key IN (
8336
WHERE col_int_key IN (
8337
SELECT col_int_nokey
8341
pk col_int_nokey col_int_key
8344
ALTER TABLE t1 ENGINE=Innodb;
8345
ALTER TABLE t2 ENGINE=Innodb;
8348
JOIN t1 AS t1b USING ( col_int_nokey )
8349
WHERE t1a.col_int_key IN (
8352
WHERE col_int_key IN (
8353
SELECT col_int_nokey
8357
pk col_int_nokey col_int_key
8361
# End of test for bug#13424134.
8363
# Bug#13414014: Extra rows in result on semijoin query with where ...
8372
INSERT INTO t1 VALUES
8373
(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c');
8378
INSERT INTO t2 VALUES
8379
('c'), (NULL), ('x'), ('q');
8385
WHERE it.a = 'x' OR it.c > it.d
8388
id select_type table type possible_keys key key_len ref rows Extra
8389
1 SIMPLE ot index a a 4 NULL 4 Using index
8390
1 SIMPLE it ALL a NULL NULL NULL 3 Using where; FirstMatch(ot); Using join buffer (Block Nested Loop)
8396
WHERE it.a = 'x' OR it.c > it.d
8403
# End of test for bug#13414014.
8405
# Bug#13545215: Missing rows on nested in-subquery with materialization
8409
col_varchar_key varchar(1),
8410
col_varchar_nokey varchar(1),
8411
KEY col_int_key (col_int_key),
8412
KEY col_varchar_key (col_varchar_key,col_int_key)
8414
INSERT INTO t1 VALUES
8415
(8,'x','x'), (0,'p','p'), (8,'c','c');
8418
col_varchar_key varchar(1),
8419
col_varchar_nokey varchar(1),
8421
KEY col_varchar_key (col_varchar_key)
8423
INSERT INTO t2 VALUES
8424
(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL),
8425
(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p');
8429
INSERT INTO t3 VALUES (7);
8430
explain SELECT grandparent1.col_varchar_nokey
8431
FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key)
8432
WHERE grandparent1.col_varchar_key IN (
8433
SELECT col_varchar_nokey
8435
WHERE col_varchar_key IN (
8436
SELECT child1.col_varchar_nokey
8437
FROM t2 AS child1 LEFT JOIN t3 AS child2
8438
ON child1.pk < child2.col_int_nokey
8441
id select_type table type possible_keys key key_len ref rows Extra
8442
1 SIMPLE grandparent1 ALL col_int_key,col_varchar_key NULL NULL NULL 3 Using where
8443
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 4 test.grandparent1.col_varchar_key 1 NULL
8444
1 SIMPLE grandparent2 index col_int_key col_int_key 5 NULL 3 Using where; Using index; Using join buffer (Block Nested Loop)
8445
2 MATERIALIZED child1 ALL NULL NULL NULL NULL 8 NULL
8446
2 MATERIALIZED child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop)
8447
2 MATERIALIZED parent1 ALL col_varchar_key NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop)
8448
SELECT grandparent1.col_varchar_nokey
8449
FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key)
8450
WHERE grandparent1.col_varchar_key IN (
8451
SELECT col_varchar_nokey
8453
WHERE col_varchar_key IN (
8454
SELECT child1.col_varchar_nokey
8455
FROM t2 AS child1 LEFT JOIN t3 AS child2
8456
ON child1.pk < child2.col_int_nokey
8465
DROP TABLE t1, t2, t3;
8466
# End of test for bug#13545215.
8468
# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND
8469
# MATERIALIZATION + SEMIJOIN ON
8472
col_int_key int(11) DEFAULT NULL,
8473
col_varchar_key varchar(1) DEFAULT NULL,
8474
col_varchar_nokey varchar(1) DEFAULT NULL,
8475
KEY col_int_key (col_int_key),
8476
KEY col_varchar_key (col_varchar_key,col_int_key)
8478
INSERT INTO t1 VALUES (4,'v','v');
8479
INSERT INTO t1 VALUES (62,'v','v');
8480
INSERT INTO t1 VALUES (7,'c','c');
8481
INSERT INTO t1 VALUES (1,NULL,NULL);
8483
alias1.col_varchar_nokey AS a1_nokey,
8484
alias1.col_varchar_key AS a1_key,
8485
alias2.col_varchar_nokey AS a2_nokey
8487
t1 AS alias1, t1 AS alias2
8489
(alias1.col_varchar_nokey,alias2.col_varchar_nokey)
8493
SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key
8495
t1 AS SQ2_alias1, t1 AS SQ2_alias2
8498
id select_type table type possible_keys key key_len ref rows Extra
8499
1 SIMPLE alias1 ALL NULL NULL NULL NULL 4 Using where
8500
1 SIMPLE alias2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop)
8501
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 8 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 NULL
8502
2 MATERIALIZED SQ2_alias1 index col_varchar_key col_varchar_key 9 NULL 4 Using index
8503
2 MATERIALIZED SQ2_alias2 ALL NULL NULL NULL NULL 4 Using join buffer (Block Nested Loop)
8505
alias1.col_varchar_nokey AS a1_nokey,
8506
alias1.col_varchar_key AS a1_key,
8507
alias2.col_varchar_nokey AS a2_nokey
8509
t1 AS alias1, t1 AS alias2
8511
(alias1.col_varchar_nokey,alias2.col_varchar_nokey)
8515
SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key
8517
t1 AS SQ2_alias1, t1 AS SQ2_alias2
8520
a1_nokey a1_key a2_nokey
8532
# Bug#13541406: Wrong result with loosescan on select .. where .. in
8535
col_int_key INT NOT NULL,
8536
col_varchar_nokey VARCHAR(1) NOT NULL,
8537
KEY col_int_key (col_int_key)
8539
INSERT INTO t1 VALUES
8540
(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'),
8541
(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'),
8542
(9,'e'), (5,'i'), (0,'y'), (3,'w');
8545
col_int_key INT NOT NULL,
8546
col_varchar_key VARCHAR(1) NOT NULL,
8547
col_varchar_nokey VARCHAR(1) NOT NULL,
8549
KEY col_int_key (col_int_key),
8550
KEY col_varchar_key (col_varchar_key,col_int_key)
8552
INSERT INTO t2 VALUES
8553
(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'),
8554
(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'),
8555
(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'),
8556
(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'),
8557
(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e');
8558
# This query should never use a LooseScan strategy
8559
explain SELECT ot1.col_int_key AS field1
8560
FROM t2 AS ot1, t2 AS ot2
8561
WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN (
8562
SELECT it2.col_varchar_nokey, it1.col_varchar_key
8563
FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk);
8564
id select_type table type possible_keys key key_len ref rows Extra
8565
1 SIMPLE ot2 ALL NULL NULL NULL NULL 20 Start temporary
8566
1 SIMPLE it1 ref PRIMARY,col_varchar_key col_varchar_key 3 test.ot2.col_varchar_nokey 1 Using index
8567
1 SIMPLE it2 ref col_int_key col_int_key 4 test.it1.pk 1 Using join buffer (Batched Key Access (unique))
8568
1 SIMPLE ot1 ref col_varchar_key col_varchar_key 3 test.it2.col_varchar_nokey 1 Using index; End temporary
8569
SELECT ot1.col_int_key AS field1
8570
FROM t2 AS ot1, t2 AS ot2
8571
WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN (
8572
SELECT it2.col_varchar_nokey, it1.col_varchar_key
8573
FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk);
8592
# End of test for bug#13541406.
8594
# Bug#13576391: Missing rows on select with in-subquery and
8595
# batched-key-access=on and semijoin
8598
col_int_nokey int NOT NULL,
8599
col_varchar_key varchar(1) NOT NULL,
8600
KEY col_varchar_key (col_varchar_key)
8602
INSERT INTO t1 VALUES
8603
(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'),
8604
(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'),
8605
(6,'e'), (3,'i'), (6,'y'), (6,'w');
8607
col_int_nokey int NOT NULL,
8608
col_varchar_nokey varchar(1) NOT NULL
8610
INSERT INTO t2 VALUES
8611
(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'),
8612
(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'),
8613
(1,'q'), (6,'w'), (2,'d'), (9,'e');
8614
explain SELECT col_varchar_nokey
8616
WHERE col_varchar_nokey IN (
8617
SELECT col_varchar_key
8619
WHERE it.col_int_nokey <= it.col_int_nokey
8620
AND NOT ot.col_int_nokey < 2
8622
ORDER BY col_varchar_nokey;
8623
id select_type table type possible_keys key key_len ref rows Extra
8624
1 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
8625
1 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 1 FirstMatch(ot); Using join buffer (Batched Key Access (unique))
8626
SELECT col_varchar_nokey
8628
WHERE col_varchar_nokey IN (
8629
SELECT col_varchar_key
8631
WHERE it.col_int_nokey <= it.col_int_nokey
8632
AND NOT ot.col_int_nokey < 2
8634
ORDER BY col_varchar_nokey;
8643
ALTER TABLE t1 ENGINE=MyISAM;
8644
ALTER TABLE t2 ENGINE=MyISAM;
8645
explain SELECT col_varchar_nokey
8647
WHERE col_varchar_nokey IN (
8648
SELECT col_varchar_key
8650
WHERE it.col_int_nokey <= it.col_int_nokey
8651
AND NOT ot.col_int_nokey < 2
8653
ORDER BY col_varchar_nokey;
8654
id select_type table type possible_keys key key_len ref rows Extra
8655
1 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
8656
1 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 FirstMatch(ot); Using join buffer (Batched Key Access (unique))
8657
SELECT col_varchar_nokey
8659
WHERE col_varchar_nokey IN (
8660
SELECT col_varchar_key
8662
WHERE it.col_int_nokey <= it.col_int_nokey
8663
AND NOT ot.col_int_nokey < 2
8665
ORDER BY col_varchar_nokey;
8674
ALTER TABLE t1 ENGINE=Memory;
8675
ALTER TABLE t2 ENGINE=Memory;
8676
explain SELECT col_varchar_nokey
8678
WHERE col_varchar_nokey IN (
8679
SELECT col_varchar_key
8681
WHERE it.col_int_nokey <= it.col_int_nokey
8682
AND NOT ot.col_int_nokey < 2
8684
ORDER BY col_varchar_nokey;
8685
id select_type table type possible_keys key key_len ref rows Extra
8686
1 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using filesort
8687
1 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 FirstMatch(ot)
8688
SELECT col_varchar_nokey
8690
WHERE col_varchar_nokey IN (
8691
SELECT col_varchar_key
8693
WHERE it.col_int_nokey <= it.col_int_nokey
8694
AND NOT ot.col_int_nokey < 2
8696
ORDER BY col_varchar_nokey;
8706
# End of test for bug#13576391.
8708
# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON"
8712
col_varchar_key VARCHAR(1),
8713
col_varchar_nokey VARCHAR(1),
8714
KEY (col_varchar_key)
8716
INSERT INTO t1 VALUES (100,'m','m'),
8717
(200,'b','b'), (300,'x','x');
8719
col_varchar_key VARCHAR(1),
8720
col_varchar_nokey VARCHAR(1),
8721
KEY (col_varchar_key)
8723
INSERT INTO t2 VALUES ('b','b');
8725
col_varchar_key VARCHAR(1),
8726
col_varchar_nokey VARCHAR(1),
8727
KEY (col_varchar_key)
8729
INSERT INTO t3 VALUES ('k','k');
8730
EXPLAIN SELECT GP1.id
8731
FROM t1 AS GP1 JOIN t3 AS GP2
8732
ON GP2.col_varchar_key <> GP1.col_varchar_nokey
8733
WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey)
8735
SELECT col_varchar_nokey, col_varchar_nokey
8737
WHERE col_varchar_nokey
8738
IN ( SELECT col_varchar_key
8739
FROM t2 LEFT JOIN t3 USING (col_varchar_key) )
8742
id select_type table type possible_keys key key_len ref rows Extra
8743
1 SIMPLE GP2 system NULL NULL NULL NULL 1 NULL
8744
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where
8745
1 SIMPLE GP1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop)
8746
2 MATERIALIZED t2 index col_varchar_key col_varchar_key 4 NULL 1 Using index
8747
2 MATERIALIZED t3 ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 Using index
8748
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop)
8750
FROM t1 AS GP1 JOIN t3 AS GP2
8751
ON GP2.col_varchar_key <> GP1.col_varchar_nokey
8752
WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey)
8754
SELECT col_varchar_nokey, col_varchar_nokey
8756
WHERE col_varchar_nokey
8757
IN ( SELECT col_varchar_key
8758
FROM t2 LEFT JOIN t3 USING (col_varchar_key) )
8763
DROP TABLE t1,t2,t3;
8765
# Bug #13596176: Missing row on select with nested in clause when
8766
# matr=on and bnl=off + MyISAM
8769
int_key int DEFAULT NULL,
8770
vc_key varchar(1) DEFAULT NULL,
8771
vc_nokey varchar(1) DEFAULT NULL,
8772
KEY int_key (int_key),
8773
KEY vc_key (vc_key, int_key)
8775
INSERT INTO t1 VALUES
8776
(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'),
8777
(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL),
8778
(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'),
8779
(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'),
8780
(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c');
8782
int_key int DEFAULT NULL,
8783
vc_key varchar(1) DEFAULT NULL,
8784
KEY int_key (int_key),
8785
KEY vc_key (vc_key, int_key)
8787
INSERT INTO t2 VALUES (8,'g');
8788
explain SELECT vc_key
8790
WHERE (vc_nokey, vc_key ) IN
8791
(SELECT vc_nokey, vc_nokey
8794
(SELECT child1.vc_key
8795
FROM t2 AS child1 JOIN t1 AS child2 USING (int_key)
8798
id select_type table type possible_keys key key_len ref rows Extra
8799
1 SIMPLE child1 index int_key,vc_key vc_key 9 NULL 1 Using where; Using index; Start temporary
8800
1 SIMPLE outr ref vc_key vc_key 4 test.child1.vc_key 3 Using where; Using join buffer (Batched Key Access (unique))
8801
1 SIMPLE child2 ref int_key int_key 5 test.child1.int_key 3 Using index
8802
1 SIMPLE middle ALL NULL NULL NULL NULL 20 Using where; End temporary; Using join buffer (Block Nested Loop)
8805
WHERE (vc_nokey, vc_key ) IN
8806
(SELECT vc_nokey, vc_nokey
8809
(SELECT child1.vc_key
8810
FROM t2 AS child1 JOIN t1 AS child2 USING (int_key)
8816
# End of test for bug#13596176.
8818
# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS
8819
# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO
8820
# ROWS + INDEX DOES NOT RETURN NULL
8823
pk int(11) PRIMARY KEY,
8825
KEY int_key (int_key)
8827
INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0);
8828
SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2);
8831
SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4);
8834
SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6;
8838
# BUG#13726217: Crash in Item_ident::fix_after_pullout()
8839
CREATE TABLE t1(a INTEGER) engine=innodb;
8840
INSERT INTO t1 VALUES (0);
8847
(SELECT elt(a, 0) AS b
8855
# End of test for bug#13726217.
8856
# BUG#13773979: Missing rows on second execution of prepared statement
8860
col_varchar_key VARCHAR(1)
8862
INSERT INTO t1 VALUES
8863
(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'),
8864
(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v');
8865
CREATE VIEW v1 AS SELECT * FROM t1;
8868
WHERE col_int_key IN (
8869
SELECT alias1.col_int_nokey AS field1
8871
WHERE alias1.col_varchar_key < 'v'
8873
col_int_nokey col_int_key col_varchar_key
8878
prepare stmt FROM "SELECT *
8880
WHERE col_int_key IN (
8881
SELECT alias1.col_int_nokey AS field1
8883
WHERE alias1.col_varchar_key < 'v'
8886
col_int_nokey col_int_key col_varchar_key
8892
col_int_nokey col_int_key col_varchar_key
8897
DEALLOCATE PREPARE stmt;
8900
# End of test for bug#13773979.
8902
# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN
8903
# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER
8906
col_int_key INT(11) NOT NULL,
8907
col_datetime_key DATETIME NOT NULL,
8908
col_varchar_key VARCHAR(1) NOT NULL,
8909
col_varchar_nokey VARCHAR(1) NOT NULL,
8910
KEY col_int_key (col_int_key),
8911
KEY col_datetime_key (col_datetime_key),
8912
KEY col_varchar_key (col_varchar_key,col_int_key)
8914
INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j');
8915
INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v');
8917
col_int_key INT(11) NOT NULL,
8918
col_datetime_key DATETIME NOT NULL,
8919
col_varchar_key VARCHAR(1) NOT NULL,
8920
col_varchar_nokey VARCHAR(1) NOT NULL,
8921
KEY col_int_key (col_int_key),
8922
KEY col_datetime_key (col_datetime_key),
8923
KEY col_varchar_key (col_varchar_key,col_int_key)
8925
INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b');
8926
SET @old_depth=@@optimizer_search_depth;
8927
SET optimizer_search_depth=4;
8928
EXPLAIN SELECT col_datetime_key
8930
WHERE col_datetime_key IN (
8931
SELECT alias1.col_datetime_key
8933
LEFT JOIN t1 as alias3
8934
STRAIGHT_JOIN ( t2 AS alias4
8936
ON alias5.col_varchar_key <= alias4.col_varchar_nokey )
8937
ON alias5.col_int_key < alias4.col_int_key
8938
ON alias5.col_varchar_key = alias4.col_varchar_key
8940
id select_type table type possible_keys key key_len ref rows Extra
8941
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
8942
1 SIMPLE outr index col_datetime_key col_datetime_key 5 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop)
8943
2 MATERIALIZED alias1 index NULL col_datetime_key 5 NULL 2 Using index
8944
2 MATERIALIZED alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 NULL
8945
2 MATERIALIZED alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index
8946
2 MATERIALIZED alias3 index NULL col_int_key 4 NULL 2 Using index
8947
SELECT col_datetime_key
8949
WHERE col_datetime_key IN (
8950
SELECT alias1.col_datetime_key
8952
LEFT JOIN t1 as alias3
8953
STRAIGHT_JOIN ( t2 AS alias4
8955
ON alias5.col_varchar_key <= alias4.col_varchar_nokey )
8956
ON alias5.col_int_key < alias4.col_int_key
8957
ON alias5.col_varchar_key = alias4.col_varchar_key
8963
SET @@optimizer_search_depth=@old_depth;
8965
# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT
8966
# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
8970
col_varchar_key VARCHAR(1),
8971
KEY col_int_key (col_int_key),
8972
KEY col_varchar_key (col_varchar_key)
8974
INSERT INTO t1 VALUES (8,'x');
8976
col_varchar_key VARCHAR(1),
8977
KEY col_varchar_key (col_varchar_key)
8979
INSERT INTO t2 VALUES ('x'), ('y');
8980
explain SELECT MIN(col_int_key)
8983
SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
8984
FROM t1 as t1_inner JOIN t2
8985
ON t2.col_varchar_key = t1_inner.col_varchar_key
8987
id select_type table type possible_keys key key_len ref rows Extra
8988
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
8989
2 SUBQUERY t1_inner system col_varchar_key NULL NULL NULL 1 NULL
8990
2 SUBQUERY t2 ref col_varchar_key col_varchar_key 4 const 1 Using index
8991
SELECT MIN(col_int_key)
8994
SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
8995
FROM t1 as t1_inner JOIN t2
8996
ON t2.col_varchar_key = t1_inner.col_varchar_key
9000
# Bug#13838810: Segfault in evaluate_null_complemented_join_record
9003
col_int_nokey int DEFAULT NULL,
9004
col_int_key int DEFAULT NULL,
9005
col_varchar_key varchar(1) DEFAULT NULL,
9007
KEY col_int_key (col_int_key),
9008
KEY col_varchar_key (col_varchar_key,col_int_key)
9010
INSERT INTO t1 VALUES (10,NULL,8,'x');
9013
col_varchar_nokey varchar(1) DEFAULT NULL,
9016
INSERT INTO t2 VALUES (1,'x');
9019
col_varchar_key varchar(1) DEFAULT NULL,
9020
col_varchar_nokey varchar(1) DEFAULT NULL,
9022
KEY col_varchar_key (col_varchar_key)
9024
INSERT INTO t3 VALUES
9025
(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL);
9026
EXPLAIN SELECT table1.pk,table2.pk, table3.pk
9028
LEFT JOIN t1 AS table2
9029
LEFT JOIN t1 AS table3
9030
ON table3.col_int_key = table2.col_int_key
9031
ON table3.pk = table2.col_int_nokey AND
9032
table1.col_varchar_nokey IN (
9033
SELECT subquery3_t1.col_varchar_nokey
9034
FROM t3 AS subquery3_t1
9035
LEFT JOIN t1 AS subquery3_t2
9036
ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key
9037
WHERE subquery3_t2.col_int_nokey <> 9
9040
id select_type table type possible_keys key key_len ref rows Extra
9041
1 SIMPLE table1 ALL NULL NULL NULL NULL 1 NULL
9042
1 SIMPLE table2 ALL col_int_key NULL NULL NULL 1 Using where
9043
1 SIMPLE table3 eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 Using where
9044
1 SIMPLE subquery3_t2 ALL col_varchar_key NULL NULL NULL 1 Using where
9045
1 SIMPLE subquery3_t1 ref col_varchar_key col_varchar_key 4 test.subquery3_t2.col_varchar_key 1 Using where; FirstMatch(table3)
9046
SELECT table1.pk,table2.pk, table3.pk
9048
LEFT JOIN t1 AS table2
9049
LEFT JOIN t1 AS table3
9050
ON table3.col_int_key = table2.col_int_key
9051
ON table3.pk = table2.col_int_nokey AND
9052
table1.col_varchar_nokey IN (
9053
SELECT subquery3_t1.col_varchar_nokey
9054
FROM t3 AS subquery3_t1
9055
LEFT JOIN t1 AS subquery3_t2
9056
ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key
9057
WHERE subquery3_t2.col_int_nokey <> 9
9062
DROP TABLE t1, t2, t3;
9063
Extra test case for specific code coverage
9064
CREATE TABLE t1(pk INTEGER);
9065
INSERT INTO t1 VALUES(1), (2);
9067
FROM t1 AS ot1 LEFT JOIN t1 AS ot2
9068
ON ot1.pk=ot2.pk AND
9071
FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk);
9072
id select_type table type possible_keys key key_len ref rows Extra
9073
1 SIMPLE ot1 ALL NULL NULL NULL NULL 2 Start temporary
9074
1 SIMPLE ot2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
9075
1 SIMPLE it1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop)
9076
1 SIMPLE it2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
9078
FROM t1 AS ot1 LEFT JOIN t1 AS ot2
9079
ON ot1.pk=ot2.pk AND
9082
FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk);
9087
# End of test for bug#13838810.
9089
# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN
9090
# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER
9093
col_int_key INT(11) NOT NULL,
9094
col_datetime_key DATETIME NOT NULL,
9095
col_varchar_key VARCHAR(1) NOT NULL,
9096
col_varchar_nokey VARCHAR(1) NOT NULL,
9097
KEY col_int_key (col_int_key),
9098
KEY col_datetime_key (col_datetime_key),
9099
KEY col_varchar_key (col_varchar_key,col_int_key)
9101
INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j');
9102
INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v');
9104
col_int_key INT(11) NOT NULL,
9105
col_datetime_key DATETIME NOT NULL,
9106
col_varchar_key VARCHAR(1) NOT NULL,
9107
col_varchar_nokey VARCHAR(1) NOT NULL,
9108
KEY col_int_key (col_int_key),
9109
KEY col_datetime_key (col_datetime_key),
9110
KEY col_varchar_key (col_varchar_key,col_int_key)
9112
INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b');
9113
SET @old_depth=@@optimizer_search_depth;
9114
SET optimizer_search_depth=4;
9115
EXPLAIN SELECT col_datetime_key
9117
WHERE col_datetime_key IN (
9118
SELECT alias1.col_datetime_key
9120
LEFT JOIN t1 as alias3
9121
STRAIGHT_JOIN ( t2 AS alias4
9123
ON alias5.col_varchar_key <= alias4.col_varchar_nokey )
9124
ON alias5.col_int_key < alias4.col_int_key
9125
ON alias5.col_varchar_key = alias4.col_varchar_key
9127
id select_type table type possible_keys key key_len ref rows Extra
9128
1 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL
9129
1 SIMPLE outr index col_datetime_key col_datetime_key 5 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop)
9130
2 MATERIALIZED alias1 index NULL col_datetime_key 5 NULL 2 Using index
9131
2 MATERIALIZED alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 NULL
9132
2 MATERIALIZED alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index
9133
2 MATERIALIZED alias3 index NULL col_int_key 4 NULL 2 Using index
9134
SELECT col_datetime_key
9136
WHERE col_datetime_key IN (
9137
SELECT alias1.col_datetime_key
9139
LEFT JOIN t1 as alias3
9140
STRAIGHT_JOIN ( t2 AS alias4
9142
ON alias5.col_varchar_key <= alias4.col_varchar_nokey )
9143
ON alias5.col_int_key < alias4.col_int_key
9144
ON alias5.col_varchar_key = alias4.col_varchar_key
9150
SET @@optimizer_search_depth=@old_depth;
9152
# Bug#13845930: Segfault in st_join_table::and_with_condition
9158
col_varchar_1 VARCHAR(1),
9159
col_varchar_2 VARCHAR(1)
9161
INSERT INTO t2 VALUES ('x','x'), ('c','c');
9163
SELECT alias2.col_varchar_2 AS field1
9167
LEFT JOIN t2 AS alias3
9169
(SELECT sq1_alias1.col_int,
9171
FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2
9174
ON alias3.col_varchar_1 = alias2.col_varchar_2
9180
DEALLOCATE prepare stmt;
9182
# End of test for bug#13845930.
9184
# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0'
9185
# in ha_innobase::index_read
9188
pk INTEGER AUTO_INCREMENT,
9191
col_varchar_key VARCHAR(1),
9192
col_varchar_nokey VARCHAR(1),
9194
KEY (col_varchar_key)
9197
col_int_key, col_int_nokey,
9198
col_varchar_key, col_varchar_nokey
9200
(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL),
9201
(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'),
9202
(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'),
9203
(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL),
9204
(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r');
9206
pk INT AUTO_INCREMENT,
9211
) AUTO_INCREMENT=10 ENGINE=INNODB;
9212
INSERT INTO t2 (col_int_key, col_int_nokey) VALUES
9213
(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL),
9214
(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6),
9215
(NULL, 6), (0, 2), (NULL, 9), (8, 6);
9217
pk INT AUTO_INCREMENT,
9218
col_varchar_key VARCHAR(1),
9220
KEY (col_varchar_key)
9222
INSERT INTO t3 (col_varchar_key) VALUES
9223
('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'),
9224
('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p');
9226
SELECT table2.col_varchar_nokey AS field1
9228
INNER JOIN (t1 AS table2
9229
STRAIGHT_JOIN t2 AS table3
9230
ON table3.col_int_key = table2.pk AND
9231
table3.col_int_nokey = ANY
9232
(SELECT subquery1_t2.col_int_nokey AS subquery1_field1
9233
FROM t2 AS subquery1_t1
9234
RIGHT OUTER JOIN t1 AS subquery1_t2
9235
INNER JOIN t1 AS subquery1_t3
9236
ON subquery1_t3.col_int_key = subquery1_t2.pk
9237
ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey
9238
WHERE subquery1_t1.pk > 1
9241
ON table3.col_int_key IN
9242
(SELECT subquery2_t1.col_int_key AS subquery2_field1
9243
FROM t2 AS subquery2_t1
9244
RIGHT OUTER JOIN t3 AS subquery2_t2
9245
LEFT OUTER JOIN t1 AS subquery2_t3
9246
ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key
9247
ON subquery2_t3.pk = subquery2_t2.pk
9250
explain SELECT * FROM v1;
9251
id select_type table type possible_keys key key_len ref rows Extra
9252
1 SIMPLE table1 index NULL col_int_key 5 NULL 20 Using index
9253
1 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using join buffer (Block Nested Loop)
9254
1 SIMPLE table2 ALL PRIMARY NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop)
9255
1 SIMPLE table3 ref col_int_key col_int_key 5 test.table2.pk 1 Using where; Using join buffer (Batched Key Access (unique))
9256
1 SIMPLE <subquery4> eq_ref <auto_key> <auto_key> 5 test.table2.pk 1 NULL
9257
3 MATERIALIZED subquery1_t2 ALL PRIMARY NULL NULL NULL 20 Using where
9258
3 MATERIALIZED subquery1_t3 ref col_varchar_key col_varchar_key 4 test.subquery1_t2.col_varchar_nokey 1 Using where; Using join buffer (Batched Key Access (unique))
9259
3 MATERIALIZED subquery1_t1 index PRIMARY col_int_key 5 NULL 20 Using where; Using index; Using join buffer (Block Nested Loop)
9260
4 MATERIALIZED subquery2_t3 index PRIMARY,col_varchar_key col_varchar_key 4 NULL 20 Using where; Using index
9261
4 MATERIALIZED subquery2_t2 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 Using where
9262
4 MATERIALIZED subquery2_t1 index col_int_key col_int_key 5 NULL 20 Using index; Using join buffer (Block Nested Loop)
9286
DROP TABLE t1,t2,t3;
9287
# End of test for bug#13855925.
9289
# Bug#13897959: Segfault in setup_semijoin_dups_elimination()
9292
col_datetime_key DATETIME DEFAULT NULL,
9293
KEY col_datetime_key (col_datetime_key)
9295
INSERT INTO t1 VALUES
9296
('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'),
9297
('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'),
9298
('2009-09-20 09:11:48'), ('2004-03-27 09:32:04');
9300
col_date_nokey date DEFAULT NULL,
9301
col_time_key time DEFAULT NULL,
9302
col_datetime_key datetime DEFAULT NULL,
9303
col_varchar_key varchar(1) DEFAULT NULL,
9304
col_varchar_nokey varchar(1) DEFAULT NULL,
9305
KEY col_time_key (col_time_key),
9306
KEY col_datetime_key (col_datetime_key),
9307
KEY col_varchar_key(col_varchar_key)
9309
INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x');
9310
SELECT grandparent1.col_varchar_nokey
9311
FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key)
9312
WHERE grandparent1.col_varchar_nokey IN (
9313
SELECT col_varchar_nokey
9315
WHERE parent1.col_time_key > grandparent1.col_date_nokey
9319
# End of test for bug#13897959.
9321
# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN
9322
# BEST_EXTENSION_BY_LIMITED_SEARCH
9325
pk int(11) NOT NULL,
9328
col_varchar_key VARCHAR(1),
9329
col_varchar_nokey VARCHAR(1),
9331
KEY col_int_key (col_int_key),
9332
KEY col_varchar_key (col_varchar_key,col_int_key)
9334
INSERT INTO t1 VALUES (26,6,NULL,'f','f');
9335
INSERT INTO t1 VALUES (29,6,8,'c','c');
9340
col_varchar_key VARCHAR(1),
9341
col_varchar_nokey VARCHAR(1),
9343
KEY col_int_key (col_int_key),
9344
KEY col_varchar_key (col_varchar_key,col_int_key)
9346
INSERT INTO t2 VALUES (1,2,4,'v','v');
9347
INSERT INTO t2 VALUES (2,150,62,'v','v');
9348
INSERT INTO t2 VALUES (5,5,0,'x','x');
9349
INSERT INTO t2 VALUES (6,3,7,'i','i');
9350
INSERT INTO t2 VALUES (7,1,7,'e','e');
9351
CREATE VIEW view_c AS SELECT * FROM t2;
9352
PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1
9354
RIGHT JOIN t2 AS alias2
9355
INNER JOIN t1 AS alias3
9356
ON (alias3.col_varchar_key = alias2.col_varchar_key )
9358
SELECT sq1_alias1.col_varchar_nokey AS sq1_field1
9359
FROM t1 AS sq1_alias1
9361
WHERE alias3.pk IN (
9362
SELECT sq2_alias1.col_int_key AS sq2_field1
9363
FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 )
9366
EXECUTE prep_stmt_7430;
9369
EXECUTE prep_stmt_7430;
9372
EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1
9374
RIGHT JOIN t2 AS alias2
9375
INNER JOIN t1 AS alias3
9376
ON (alias3.col_varchar_key = alias2.col_varchar_key )
9378
SELECT sq1_alias1.col_varchar_nokey AS sq1_field1
9379
FROM t1 AS sq1_alias1
9381
WHERE alias3.pk IN (
9382
SELECT sq2_alias1.col_int_key AS sq2_field1
9383
FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 )
9386
id select_type table type possible_keys key key_len ref rows Extra
9387
1 SIMPLE alias3 ALL PRIMARY,col_varchar_key NULL NULL NULL 2 Using where
9388
1 SIMPLE sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index
9389
1 SIMPLE t2 ref col_int_key col_int_key 5 test.alias3.pk 2 Using index; FirstMatch(alias3)
9390
1 SIMPLE alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using index
9391
1 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(alias2)
9392
1 SIMPLE alias1 index NULL col_varchar_key 9 NULL 2 Using index
9393
PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1
9395
RIGHT JOIN t2 AS alias2
9396
INNER JOIN t1 AS alias3
9397
ON (alias3.col_varchar_key = alias2.col_varchar_key )
9399
SELECT sq1_alias1.col_varchar_nokey AS sq1_field1
9400
FROM t1 AS sq1_alias1
9402
WHERE alias3.pk IN (
9403
SELECT sq2_alias1.col_int_key AS sq2_field1
9404
FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 )
9405
WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key
9406
AND sq2_alias1.col_varchar_key < "l"
9409
EXECUTE prep_stmt_7430;
9412
EXECUTE prep_stmt_7430;
9415
EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1
9417
RIGHT JOIN t2 AS alias2
9418
INNER JOIN t1 AS alias3
9419
ON (alias3.col_varchar_key = alias2.col_varchar_key )
9421
SELECT sq1_alias1.col_varchar_nokey AS sq1_field1
9422
FROM t1 AS sq1_alias1
9424
WHERE alias3.pk IN (
9425
SELECT sq2_alias1.col_int_key AS sq2_field1
9426
FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 )
9427
WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key
9428
AND sq2_alias1.col_varchar_key < "l"
9431
id select_type table type possible_keys key key_len ref rows Extra
9432
1 SIMPLE t2 range col_int_key,col_varchar_key col_varchar_key 4 NULL 2 Using index condition; Using MRR; Start temporary
9433
1 SIMPLE alias3 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.t2.col_int_key 1 Using where; Using join buffer (Batched Key Access (unique))
9434
1 SIMPLE alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using index
9435
1 SIMPLE sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index; End temporary; Using join buffer (Block Nested Loop)
9436
1 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(sq2_alias2)
9437
1 SIMPLE alias1 index NULL col_varchar_key 9 NULL 2 Using index
9441
# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD
9442
# ON SECOND EXEC OF PREP STMT
9448
col_varchar_key VARCHAR(1),
9449
col_varchar_nokey VARCHAR(1),
9450
KEY col_varchar_key (col_varchar_key)
9452
CREATE VIEW view_b AS SELECT * FROM t1;
9453
PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1
9455
INNER JOIN t1 AS alias2
9456
ON (alias1.col_varchar_key = alias2.col_varchar_nokey
9457
AND ( alias1.col_int_key ) IN (
9458
SELECT t1.col_int_nokey
9462
WHERE alias1.col_varchar_key IN (
9463
SELECT sq2_alias2.col_varchar_nokey AS sq2_field1
9464
FROM view_b AS sq2_alias1
9465
INNER JOIN t1 AS sq2_alias2
9466
ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key )
9467
WHERE sq2_alias1.pk > alias2.pk
9470
EXECUTE prep_stmt_20421;
9472
EXECUTE prep_stmt_20421;
9474
EXPLAIN SELECT alias2.col_varchar_nokey AS field1
9476
INNER JOIN t1 AS alias2
9477
ON (alias1.col_varchar_key = alias2.col_varchar_nokey
9478
AND ( alias1.col_int_key ) IN (
9479
SELECT t1.col_int_nokey
9483
WHERE alias1.col_varchar_key IN (
9484
SELECT sq2_alias2.col_varchar_nokey AS sq2_field1
9485
FROM view_b AS sq2_alias1
9486
INNER JOIN t1 AS sq2_alias2
9487
ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key )
9488
WHERE sq2_alias1.pk > alias2.pk
9491
id select_type table type possible_keys key key_len ref rows Extra
9492
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
9493
ALTER TABLE t1 DROP INDEX col_varchar_key;
9494
PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1
9496
INNER JOIN t1 AS alias2
9497
ON (alias1.col_varchar_key = alias2.col_varchar_nokey
9498
AND ( alias1.col_int_key ) IN (
9499
SELECT t1.col_int_nokey
9503
WHERE alias1.col_varchar_key IN (
9504
SELECT sq2_alias2.col_varchar_nokey AS sq2_field1
9505
FROM view_b AS sq2_alias1
9506
INNER JOIN t1 AS sq2_alias2
9507
ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key )
9508
WHERE sq2_alias1.pk > alias2.pk
9511
EXECUTE prep_stmt_20421;
9513
EXECUTE prep_stmt_20421;
9515
EXPLAIN SELECT alias2.col_varchar_nokey AS field1
9517
INNER JOIN t1 AS alias2
9518
ON (alias1.col_varchar_key = alias2.col_varchar_nokey
9519
AND ( alias1.col_int_key ) IN (
9520
SELECT t1.col_int_nokey
9524
WHERE alias1.col_varchar_key IN (
9525
SELECT sq2_alias2.col_varchar_nokey AS sq2_field1
9526
FROM view_b AS sq2_alias1
9527
INNER JOIN t1 AS sq2_alias2
9528
ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key )
9529
WHERE sq2_alias1.pk > alias2.pk
9532
id select_type table type possible_keys key key_len ref rows Extra
9533
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
9537
# Bug#13907277: Segfault in evaluate_null_complemented_join_record
9541
col_varchar_nokey VARCHAR(1),
9542
col_varchar_key VARCHAR(1),
9545
INSERT INTO t1 VALUES (1, 'x', 'x');
9550
INSERT INTO t2 VALUES (1);
9553
col_int_nokey INTEGER,
9554
col_int_key INTEGER,
9555
col_varchar_nokey VARCHAR(1),
9558
INSERT INTO t3 VALUES (1, 6, 5, 'r');
9559
explain SELECT outer_t1.pk, outer_t2.pk
9561
RIGHT JOIN t2 AS outer_t2
9562
ON outer_t1.col_int_nokey IN
9563
(SELECT inner_t1.col_int_nokey
9565
LEFT JOIN t1 AS inner_t2
9566
INNER JOIN t1 AS inner_t3
9567
ON inner_t3.pk = inner_t2.pk
9568
ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key
9570
id select_type table type possible_keys key key_len ref rows Extra
9571
1 SIMPLE outer_t2 system NULL NULL NULL NULL 1 NULL
9572
1 SIMPLE outer_t1 ALL NULL NULL NULL NULL 1 Using where
9573
1 SIMPLE inner_t1 ALL NULL NULL NULL NULL 1 Using where
9574
1 SIMPLE inner_t2 ALL PRIMARY NULL NULL NULL 1 NULL
9575
1 SIMPLE inner_t3 eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 Using where; FirstMatch(outer_t1)
9576
SELECT outer_t1.pk, outer_t2.pk
9578
RIGHT JOIN t2 AS outer_t2
9579
ON outer_t1.col_int_nokey IN
9580
(SELECT inner_t1.col_int_nokey
9582
LEFT JOIN t1 AS inner_t2
9583
INNER JOIN t1 AS inner_t3
9584
ON inner_t3.pk = inner_t2.pk
9585
ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key
9589
DROP TABLE t1, t2, t3;
9590
# End of test for bug#13907277.
9592
# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution
9596
col_varchar_key VARCHAR(1),
9597
col_varchar_nokey VARCHAR(1)
9600
SELECT MIN(alias2.col_varchar_key) AS field1
9602
INNER JOIN (t1 AS alias2
9603
INNER JOIN t1 AS alias3
9605
(SELECT sq1_alias1.pk AS sq1_field2
9606
FROM t1 AS sq1_alias1
9608
(SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2
9609
FROM t1 AS t1_sq1_alias1
9613
ON alias3.col_varchar_nokey = alias2.col_varchar_key
9615
(SELECT sq2_alias1.pk AS sq2_field1
9616
FROM t1 AS sq2_alias1
9617
WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey
9626
DEALLOCATE PREPARE stmt;
9628
# End of test for bug#13955713.
9630
# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data()
9634
col_varchar_key VARCHAR(1),
9635
col_varchar_nokey VARCHAR(1)
9639
col_varchar_key VARCHAR(1),
9640
col_varchar_nokey VARCHAR(1)
9642
INSERT INTO t2 VALUES
9643
(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'),
9644
(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'),
9645
(18,'v','v'), (19,NULL,NULL), (20,'r','r');
9649
col_varchar_key VARCHAR(1),
9650
KEY col_int_key (col_int_key)
9652
INSERT INTO t3 VALUES
9653
(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'),
9654
(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL),
9655
(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'),
9656
(27,0,'p'), (28,NULL,'j'), (29,8,'c');
9657
CREATE VIEW view_inline_0 AS
9659
FROM t1 INNER JOIN t3
9661
CREATE VIEW view_inline_1 AS
9662
SELECT sq2_alias2.col_varchar_key AS sq2_field1,
9663
sq2_alias1.col_varchar_key AS sq2_field2
9664
FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2
9665
ON sq2_alias1.pk = sq2_alias2.col_int_key;
9666
CREATE VIEW view_inline_2 AS
9667
SELECT 'p', 'p' UNION SELECT 'k', 's';
9668
explain SELECT SUM(alias1.col_varchar_nokey) AS field2
9670
LEFT JOIN (SELECT * FROM view_inline_0) AS alias1
9671
ON alias2.col_varchar_key = alias1.col_varchar_key AND
9672
(alias2.col_varchar_nokey, alias2.col_varchar_key) IN
9673
(SELECT * FROM view_inline_1
9675
WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN
9676
(SELECT * FROM view_inline_2
9678
id select_type table type possible_keys key key_len ref rows Extra
9679
1 PRIMARY <subquery4> ALL NULL NULL NULL NULL NULL Using where
9680
1 PRIMARY <derived2> ref <auto_key0> <auto_key0> 8 <subquery4>.p,<subquery4>.My_exp_p 2 NULL
9681
1 PRIMARY alias2 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (Block Nested Loop)
9682
1 PRIMARY <subquery3> eq_ref <auto_key> <auto_key> 8 test.alias2.col_varchar_nokey,<subquery4>.p 1 NULL
9683
4 MATERIALIZED <derived7> ALL NULL NULL NULL NULL 2 NULL
9684
3 MATERIALIZED sq2_alias1 ALL NULL NULL NULL NULL 15 NULL
9685
3 MATERIALIZED sq2_alias2 ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 Using join buffer (Batched Key Access (unique))
9686
7 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
9687
8 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
9688
NULL UNION RESULT <union7,8> ALL NULL NULL NULL NULL NULL Using temporary
9689
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
9690
SELECT SUM(alias1.col_varchar_nokey) AS field2
9692
LEFT JOIN (SELECT * FROM view_inline_0) AS alias1
9693
ON alias2.col_varchar_key = alias1.col_varchar_key AND
9694
(alias2.col_varchar_nokey, alias2.col_varchar_key) IN
9695
(SELECT * FROM view_inline_1
9697
WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN
9698
(SELECT * FROM view_inline_2
9702
DROP VIEW view_inline_0, view_inline_1, view_inline_2;
9703
DROP TABLE t1, t2, t3;
9704
# End of test for bug#13956813.
9706
# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
9709
pk INTEGER AUTO_INCREMENT,
9710
col_int_nokey INTEGER,
9711
col_int_key INTEGER,
9712
col_varchar_key VARCHAR(1),
9713
col_varchar_nokey VARCHAR(1),
9716
KEY (col_varchar_key, col_int_key)
9718
INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
9720
(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
9721
(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
9722
(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
9723
(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
9724
(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
9726
pk INTEGER AUTO_INCREMENT,
9727
col_int_nokey INTEGER NOT NULL,
9728
col_time_key TIME NOT NULL,
9729
col_time_nokey TIME NOT NULL,
9733
INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
9734
(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
9735
(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
9736
(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
9737
(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
9738
(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
9739
(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
9740
(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
9741
(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
9742
(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
9743
(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
9744
explain SELECT ot1.col_int_key AS x
9747
ON ot2.col_varchar_nokey > ot1.col_varchar_key
9748
WHERE (ot1.col_int_nokey, ot1.pk) IN
9749
(SELECT it1.pk AS x,
9750
it1.col_int_nokey AS y
9753
ON it2.col_time_nokey = it1.col_time_key
9754
) AND ot1.pk IS NULL
9756
id select_type table type possible_keys key key_len ref rows Extra
9757
1 SIMPLE ot1 const PRIMARY,col_varchar_key PRIMARY 4 const 1 Using where
9758
1 SIMPLE it1 eq_ref PRIMARY,col_time_key PRIMARY 4 test.ot1.col_int_nokey 1 Using where
9759
1 SIMPLE it2 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
9760
1 SIMPLE ot2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop)
9761
SELECT ot1.col_int_key AS x
9764
ON ot2.col_varchar_nokey > ot1.col_varchar_key
9765
WHERE (ot1.col_int_nokey, ot1.pk) IN
9766
(SELECT it1.pk AS x,
9767
it1.col_int_nokey AS y
9770
ON it2.col_time_nokey = it1.col_time_key
9771
) AND ot1.pk IS NULL
9775
# End of test for bug#13974177.
9777
# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key...
9782
col_varchar_key VARCHAR(1),
9784
KEY col_varchar_key (col_varchar_key,col_int_key)
9789
col_varchar_key VARCHAR(1),
9790
col_varchar_nokey VARCHAR(1),
9796
explain SELECT table1.pk AS field1
9797
FROM ( SELECT subquery1_t1. *
9798
FROM t2 AS subquery1_t1
9799
JOIN t2 AS subquery1_t2
9800
ON subquery1_t2.pk = subquery1_t1.pk) AS table1
9801
STRAIGHT_JOIN t2 AS table2
9802
ON table1.col_int_key IN (SELECT 7 FROM t3)
9803
WHERE table1.col_varchar_nokey IN
9804
(SELECT subquery3_t1.col_varchar_key AS subquery3_field1
9805
FROM t1 AS subquery3_t1
9808
id select_type table type possible_keys key key_len ref rows Extra
9809
1 PRIMARY subquery3_t1 index col_varchar_key col_varchar_key 9 NULL 0 Using where; Using index; LooseScan
9810
1 PRIMARY <derived2> ref <auto_key0> <auto_key0> 9 const,test.subquery3_t1.col_varchar_key 2 NULL
9811
1 PRIMARY t3 ALL NULL NULL NULL NULL 0 FirstMatch(<derived2>); Using join buffer (Block Nested Loop)
9812
1 PRIMARY table2 index NULL PRIMARY 4 NULL 1 Using index; Using join buffer (Block Nested Loop)
9813
2 DERIVED subquery1_t1 ALL PRIMARY NULL NULL NULL 1 NULL
9814
2 DERIVED subquery1_t2 eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 Using index
9815
SELECT table1.pk AS field1
9816
FROM ( SELECT subquery1_t1. *
9817
FROM t2 AS subquery1_t1
9818
JOIN t2 AS subquery1_t2
9819
ON subquery1_t2.pk = subquery1_t1.pk) AS table1
9820
STRAIGHT_JOIN t2 AS table2
9821
ON table1.col_int_key IN (SELECT 7 FROM t3)
9822
WHERE table1.col_varchar_nokey IN
9823
(SELECT subquery3_t1.col_varchar_key AS subquery3_field1
9824
FROM t1 AS subquery3_t1
9828
DROP TABLE t1, t2, t3;
9829
# End of test for bug#13971022.
9831
# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH
9832
# TIME/DATETIME COMPARE" - Subquery part of test.
9834
SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35');
9838
col_int_key INT NOT NULL,
9840
KEY col_int_key (col_int_key)
9842
INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3),
9843
(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6),
9844
(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9),
9845
(27,3,5), (28,6,0), (29,6,3);
9847
col_int_nokey INT NOT NULL,
9848
col_datetime_key DATETIME NOT NULL,
9849
col_varchar_key VARCHAR(1) NOT NULL,
9850
KEY col_datetime_key (col_datetime_key),
9851
KEY col_varchar_key (col_varchar_key)
9853
INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k');
9856
KEY col_time_key (col_time_key)
9858
INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'),
9859
('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'),
9860
('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'),
9861
('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'),
9862
('02:59:24'), ('00:01:58');
9863
EXPLAIN EXTENDED SELECT outr.col_int_nokey
9865
STRAIGHT_JOIN t3 AS outr2
9866
ON outr2.col_time_key > outr.col_datetime_key
9867
WHERE outr.col_int_nokey IN (
9870
WHERE innr.pk >= innr.col_int_nokey
9872
outr.col_int_nokey <= 6
9874
outr.col_varchar_key IS NULL
9876
id select_type table type possible_keys key key_len ref rows filtered Extra
9877
1 SIMPLE outr ALL col_datetime_key NULL NULL NULL 1 100.00 Using where
9878
1 SIMPLE innr ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 100.00 Using where; FirstMatch(outr); Using join buffer (Batched Key Access (unique))
9879
1 SIMPLE outr2 ALL col_time_key NULL NULL NULL 20 100.00 Range checked for each record (index map: 0x1)
9881
Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` semi join (`test`.`t1` `innr`) straight_join `test`.`t3` `outr2` where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (`test`.`outr2`.`col_time_key` > `test`.`outr`.`col_datetime_key`))
9882
SELECT outr.col_int_nokey
9884
STRAIGHT_JOIN t3 AS outr2
9885
ON outr2.col_time_key > outr.col_datetime_key
9886
WHERE outr.col_int_nokey IN (
9889
WHERE innr.pk >= innr.col_int_nokey
9891
outr.col_int_nokey <= 6
9893
outr.col_varchar_key IS NULL
9916
DROP TABLE t1,t2,t3;
9917
SET TIMESTAMP = DEFAULT;
9918
# End of test for bug#13623473.
9920
# Bug#13980954: Missing data on left join + null value + where..in
9926
INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x');
9931
INSERT INTO t2 VALUES
9932
(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j');
9933
explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik
9934
FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc
9935
WHERE t2.vc IN (SELECT vc FROM t2 AS t3);
9944
"access_type": "ALL",
9947
"attached_condition": "(`test`.`t2`.`vc` is not null)"
9952
"table_name": "<subquery2>",
9953
"access_type": "eq_ref",
9954
"key": "<auto_key>",
9960
"materialized_from_subquery": {
9961
"using_temporary_table": true,
9965
"access_type": "ALL",
9976
"access_type": "ALL",
9979
"using_join_buffer": "Block Nested Loop",
9980
"attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)"
9987
Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` semi join (`test`.`t2` `t3`) left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) where (`<subquery2>`.`vc` = `test`.`t2`.`vc`)
9988
SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik
9989
FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc
9990
WHERE t2.vc IN (SELECT vc FROM t2 AS t3);
10000
# End of test for bug#13980954.
10002
# Bug#14048292: Segfault in Item_field::result_type on 2nd execution
10003
# of prep stmt with join of view
10008
INSERT INTO t1 VALUES (0), (1);
10009
CREATE VIEW view_t1 AS SELECT * FROM t1;
10010
explain SELECT alias1.col_int
10012
LEFT JOIN view_t1 AS alias2
10013
ON alias1.col_int IN
10014
(SELECT sq1_alias1.col_int
10015
FROM t1 AS sq1_alias1
10017
id select_type table type possible_keys key key_len ref rows Extra
10018
1 SIMPLE alias1 ALL NULL NULL NULL NULL 2 NULL
10019
1 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(alias1)
10020
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL
10021
PREPARE stmt FROM "SELECT alias1.col_int
10023
LEFT JOIN view_t1 AS alias2
10024
ON alias1.col_int IN
10025
(SELECT sq1_alias1.col_int
10026
FROM t1 AS sq1_alias1
10040
DEALLOCATE PREPARE stmt;
10043
# End of test for bug#14048292.
10045
# Bug#14064201: Missing data on join of derived table + WHERE .. IN
10046
# with two operands
10049
col_varchar_nokey VARCHAR(1)
10051
INSERT INTO t1 VALUES
10052
('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'),
10053
('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w');
10055
col_varchar_key VARCHAR(1),
10056
col_varchar_nokey VARCHAR(1),
10057
KEY col_varchar_key(col_varchar_key)
10059
INSERT INTO t2 VALUES
10060
('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y');
10061
explain format=json SELECT *
10062
FROM (SELECT * FROM t2) AS derived1
10064
USING (col_varchar_nokey)
10065
WHERE (col_varchar_nokey, col_varchar_nokey) IN
10066
(SELECT col_varchar_nokey, col_varchar_key
10067
FROM t2 AS derived2
10076
"table_name": "<subquery3>",
10077
"access_type": "ALL",
10078
"attached_condition": "((`<subquery3>`.`col_varchar_key` = `<subquery3>`.`col_varchar_nokey`) and (`<subquery3>`.`col_varchar_nokey` is not null))",
10079
"materialized_from_subquery": {
10080
"using_temporary_table": true,
10083
"table_name": "derived2",
10084
"access_type": "ALL",
10090
"attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)"
10098
"table_name": "derived1",
10099
"access_type": "ref",
10103
"key": "<auto_key0>",
10104
"used_key_parts": [
10105
"col_varchar_nokey"
10109
"<subquery3>.col_varchar_nokey"
10113
"materialized_from_subquery": {
10114
"using_temporary_table": true,
10115
"dependent": false,
10120
"table_name": "t2",
10121
"access_type": "ALL",
10131
"table_name": "t1",
10132
"access_type": "ALL",
10135
"using_join_buffer": "Block Nested Loop",
10136
"attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)"
10143
Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` semi join (`test`.`t2` `derived2`) left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) where ((`<subquery3>`.`col_varchar_key` = `<subquery3>`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `<subquery3>`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`))
10145
FROM (SELECT * FROM t2) AS derived1
10147
USING (col_varchar_nokey)
10148
WHERE (col_varchar_nokey, col_varchar_nokey) IN
10149
(SELECT col_varchar_nokey, col_varchar_key
10150
FROM t2 AS derived2
10152
col_varchar_nokey col_varchar_key
10165
col_int_nokey int NOT NULL,
10166
col_int_key int NOT NULL,
10167
KEY col_int_key (col_int_key)
10169
INSERT INTO t1 VALUES
10170
(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3),
10171
(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3);
10173
col_int_nokey int NOT NULL,
10174
col_int_key int NOT NULL,
10175
KEY col_int_key (col_int_key)
10177
INSERT INTO t2 VALUES
10178
(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2),
10179
(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8);
10180
explain format=json SELECT grandparent1.*
10181
FROM t1 AS grandparent1
10182
LEFT JOIN t1 USING (col_int_nokey)
10183
WHERE (col_int_nokey, col_int_nokey) IN
10184
(SELECT col_int_nokey, col_int_key
10194
"table_name": "grandparent1",
10195
"access_type": "ALL",
10198
"attached_condition": "((`test`.`grandparent1`.`col_int_nokey` is not null) and (`test`.`grandparent1`.`col_int_nokey` is not null))"
10203
"table_name": "<subquery2>",
10204
"access_type": "eq_ref",
10205
"key": "<auto_key>",
10208
"test.grandparent1.col_int_nokey",
10209
"test.grandparent1.col_int_nokey"
10212
"materialized_from_subquery": {
10213
"using_temporary_table": true,
10216
"table_name": "t2",
10217
"access_type": "ALL",
10223
"attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)"
10231
"table_name": "t1",
10232
"access_type": "ALL",
10235
"using_join_buffer": "Block Nested Loop",
10236
"attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)"
10243
Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` semi join (`test`.`t2`) left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) where ((`<subquery2>`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery2>`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`))
10244
SELECT grandparent1.*
10245
FROM t1 AS grandparent1
10246
LEFT JOIN t1 USING (col_int_nokey)
10247
WHERE (col_int_nokey, col_int_nokey) IN
10248
(SELECT col_int_nokey, col_int_key
10251
col_int_nokey col_int_key
10268
col_datetime_key datetime,
10269
col_varchar_key varchar(1),
10270
col_varchar_nokey varchar(1),
10272
KEY col_int_key (col_int_key),
10273
KEY col_datetime_key (col_datetime_key),
10274
KEY col_varchar_key (col_varchar_key,col_int_key)
10276
INSERT INTO t1 VALUES
10277
(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'),
10278
(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'),
10279
(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'),
10280
(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'),
10281
(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'),
10282
(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'),
10283
(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'),
10284
(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'),
10285
(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'),
10286
(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w');
10290
col_datetime_key datetime,
10291
col_varchar_key varchar(1),
10292
col_varchar_nokey varchar(1),
10294
KEY col_int_key (col_int_key),
10295
KEY col_datetime_key (col_datetime_key),
10296
KEY col_varchar_key (col_varchar_key,col_int_key)
10298
INSERT INTO t2 VALUES
10299
(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'),
10300
(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'),
10301
(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'),
10302
(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'),
10303
(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'),
10304
(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'),
10305
(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'),
10306
(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'),
10307
(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'),
10308
(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e');
10309
SELECT alias1.col_datetime_key
10311
RIGHT JOIN t2 AS alias2
10313
ON alias3.pk = alias2.pk
10314
ON alias3.col_varchar_nokey = alias2.col_varchar_key OR
10315
alias2.col_varchar_nokey
10316
WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN
10317
(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey
10318
FROM t1 AS sq2_alias1, t1 AS sq2_alias2
10319
WHERE sq2_alias2.col_int_key < 2);
10321
1900-01-01 00:00:00
10322
1900-01-01 00:00:00
10323
1900-01-01 00:00:00
10324
1900-01-01 00:00:00
10325
1900-01-01 00:00:00
10326
1900-01-01 00:00:00
10327
1900-01-01 00:00:00
10328
1900-01-01 00:00:00
10329
1900-01-01 00:00:00
10330
1900-01-01 00:00:00
10331
2001-01-20 12:47:23
10332
2001-01-20 12:47:23
10333
2001-02-15 03:08:38
10334
2001-02-15 03:08:38
10335
2002-01-16 00:00:00
10336
2002-01-16 00:00:00
10337
2002-02-13 17:30:06
10338
2002-02-13 17:30:06
10339
2002-08-20 22:48:00
10340
2002-08-20 22:48:00
10341
2002-08-25 20:35:06
10342
2002-08-25 20:35:06
10343
2002-12-08 11:34:58
10344
2002-12-08 11:34:58
10345
2004-10-02 20:31:15
10346
2004-10-02 20:31:15
10347
2005-08-15 00:00:00
10348
2005-08-15 00:00:00
10349
2006-10-12 04:32:53
10350
2006-10-12 04:32:53
10351
2007-05-28 00:00:00
10352
2007-05-28 00:00:00
10353
2008-05-16 08:09:06
10354
2008-05-16 08:09:06
10355
2008-07-02 00:00:00
10356
2008-07-02 00:00:00
10357
2008-09-27 00:34:58
10358
2008-09-27 00:34:58
10359
2009-07-25 09:21:20
10360
2009-07-25 09:21:20
10361
ALTER TABLE t1 DISABLE KEYS;
10362
ALTER TABLE t2 DISABLE KEYS;
10363
explain format=json SELECT alias1.col_datetime_key
10365
RIGHT JOIN t2 AS alias2
10367
ON alias3.pk = alias2.pk
10368
ON alias3.col_varchar_nokey = alias2.col_varchar_key OR
10369
alias2.col_varchar_nokey
10370
WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN
10371
(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey
10372
FROM t1 AS sq2_alias1, t1 AS sq2_alias2
10373
WHERE sq2_alias2.col_int_key < 2);
10381
"table_name": "<subquery2>",
10382
"access_type": "ALL",
10383
"attached_condition": "(`<subquery2>`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`)",
10384
"materialized_from_subquery": {
10385
"using_temporary_table": true,
10390
"table_name": "sq2_alias1",
10391
"access_type": "ALL",
10398
"table_name": "sq2_alias2",
10399
"access_type": "ALL",
10402
"using_join_buffer": "Block Nested Loop",
10403
"attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_int_key` < 2))"
10413
"table_name": "alias2",
10414
"access_type": "ALL",
10420
"using_join_buffer": "Block Nested Loop",
10421
"attached_condition": "(`test`.`alias2`.`col_varchar_key` = `<subquery2>`.`col_varchar_key`)"
10426
"table_name": "alias3",
10427
"access_type": "eq_ref",
10432
"used_key_parts": [
10441
"using_join_buffer": "Batched Key Access (unique)"
10446
"table_name": "alias1",
10447
"access_type": "ALL",
10450
"using_join_buffer": "Block Nested Loop",
10451
"attached_condition": "<if>(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or `test`.`alias2`.`col_varchar_nokey`), true)"
10458
Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`)) or `test`.`alias2`.`col_varchar_nokey`)) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`<subquery2>`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = `<subquery2>`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_int_key` < 2))
10459
SELECT alias1.col_datetime_key
10461
RIGHT JOIN t2 AS alias2
10463
ON alias3.pk = alias2.pk
10464
ON alias3.col_varchar_nokey = alias2.col_varchar_key OR
10465
alias2.col_varchar_nokey
10466
WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN
10467
(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey
10468
FROM t1 AS sq2_alias1, t1 AS sq2_alias2
10469
WHERE sq2_alias2.col_int_key < 2);
10471
2002-02-13 17:30:06
10472
2002-02-13 17:30:06
10473
2008-09-27 00:34:58
10474
2008-09-27 00:34:58
10475
2007-05-28 00:00:00
10476
2007-05-28 00:00:00
10477
2009-07-25 09:21:20
10478
2009-07-25 09:21:20
10479
2002-01-16 00:00:00
10480
2002-01-16 00:00:00
10481
2006-10-12 04:32:53
10482
2006-10-12 04:32:53
10483
2001-02-15 03:08:38
10484
2001-02-15 03:08:38
10485
2004-10-02 20:31:15
10486
2004-10-02 20:31:15
10487
2002-08-20 22:48:00
10488
2002-08-20 22:48:00
10489
1900-01-01 00:00:00
10490
1900-01-01 00:00:00
10491
2005-08-15 00:00:00
10492
2005-08-15 00:00:00
10493
1900-01-01 00:00:00
10494
1900-01-01 00:00:00
10495
2008-05-16 08:09:06
10496
2008-05-16 08:09:06
10497
2001-01-20 12:47:23
10498
2001-01-20 12:47:23
10499
2008-07-02 00:00:00
10500
2008-07-02 00:00:00
10501
1900-01-01 00:00:00
10502
1900-01-01 00:00:00
10503
2002-12-08 11:34:58
10504
2002-12-08 11:34:58
10505
1900-01-01 00:00:00
10506
1900-01-01 00:00:00
10507
1900-01-01 00:00:00
10508
1900-01-01 00:00:00
10509
2002-08-25 20:35:06
10510
2002-08-25 20:35:06
10512
# End of test for bug#14064201.
10513
set @@optimizer_switch=@old_opt_switch;
10515
set optimizer_switch=default;
10516
set optimizer_switch=default;