1
set @save_optimizer_switch_jcl6=@@optimizer_switch;
2
set @@optimizer_switch='optimize_join_buffer_size=on';
3
set @@optimizer_switch='semijoin_with_cache=on';
4
set @@optimizer_switch='outer_join_with_cache=on';
5
set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
6
set join_cache_level=6;
7
show variables like 'join_cache_level';
10
set @optimizer_switch_for_join_nested_test=@@optimizer_switch;
11
set @join_cache_level_for_join_nested_test=@@join_cache_level;
12
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;
13
SET @save_optimizer_switch=@@optimizer_switch;
14
SET optimizer_switch=ifnull(@optimizer_switch_for_join_nested_test,'outer_join_with_cache=off');
15
set join_cache_level=@join_cache_level_for_join_nested_test;
16
CREATE TABLE t0 (a int, b int, c int);
17
CREATE TABLE t1 (a int, b int, c int);
18
CREATE TABLE t2 (a int, b int, c int);
19
CREATE TABLE t3 (a int, b int, c int);
20
CREATE TABLE t4 (a int, b int, c int);
21
CREATE TABLE t5 (a int, b int, c int);
22
CREATE TABLE t6 (a int, b int, c int);
23
CREATE TABLE t7 (a int, b int, c int);
24
CREATE TABLE t8 (a int, b int, c int);
25
CREATE TABLE t9 (a int, b int, c int);
26
INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0);
27
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
28
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
29
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
30
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
31
INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0);
32
INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0);
33
INSERT INTO t7 VALUES (1,1,0), (2,2,0);
34
INSERT INTO t8 VALUES (0,2,0), (1,2,0);
35
INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0);
52
SELECT t3.a,t3.b,t4.a,t4.b
59
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
69
3 3 NULL NULL NULL NULL
70
5 3 NULL NULL NULL NULL
71
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
75
ON t3.a=1 AND t2.b=t4.b;
79
3 3 NULL NULL NULL NULL
80
5 3 NULL NULL NULL NULL
82
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
87
WHERE t3.a=1 OR t3.c IS NULL;
88
id select_type table type possible_keys key key_len ref rows filtered Extra
89
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
90
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
91
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
93
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where ((`test`.`t3`.`a` = 1) or isnull(`test`.`t3`.`c`))
94
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
99
WHERE t3.a=1 OR t3.c IS NULL;
103
3 3 NULL NULL NULL NULL
104
5 3 NULL NULL NULL NULL
105
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
110
WHERE t3.a>1 OR t3.c IS NULL;
114
3 3 NULL NULL NULL NULL
115
5 3 NULL NULL NULL NULL
122
SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
137
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
155
3 3 NULL NULL NULL NULL NULL NULL
156
5 3 NULL NULL NULL NULL NULL NULL
158
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
163
WHERE t3.a>1 OR t3.c IS NULL;
164
id select_type table type possible_keys key key_len ref rows filtered Extra
165
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
166
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
167
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
168
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
170
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where ((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`))
171
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
176
WHERE t3.a>1 OR t3.c IS NULL;
184
3 3 NULL NULL NULL NULL NULL NULL
185
5 3 NULL NULL NULL NULL NULL NULL
187
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
192
WHERE (t3.a>1 OR t3.c IS NULL) AND
193
(t5.a<3 OR t5.c IS NULL);
194
id select_type table type possible_keys key key_len ref rows filtered Extra
195
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
196
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
197
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
198
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
200
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`)) and ((`test`.`t5`.`a` < 3) or isnull(`test`.`t5`.`c`)))
201
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b
206
WHERE (t3.a>1 OR t3.c IS NULL) AND
207
(t5.a<3 OR t5.c IS NULL);
211
3 3 NULL NULL NULL NULL NULL NULL
212
5 3 NULL NULL NULL NULL NULL NULL
224
SELECT t6.a,t6.b,t7.a,t7.b
239
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
243
ON t7.b=t8.b AND t6.b < 10;
244
id select_type table type possible_keys key key_len ref rows filtered Extra
245
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00
246
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
247
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
249
Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` is not null))) where 1
250
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
254
ON t7.b=t8.b AND t6.b < 10;
271
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
278
ON t7.b=t8.b AND t6.b < 10
280
ON t6.b >= 2 AND t5.b=t7.b;
286
3 1 3 2 1 1 NULL NULL
287
3 1 6 2 1 1 NULL NULL
288
3 3 NULL NULL NULL NULL NULL NULL
289
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
296
ON t7.b=t8.b AND t6.b < 10
298
ON t6.b >= 2 AND t5.b=t7.b AND
299
(t8.a < 1 OR t8.c IS NULL);
303
3 1 3 2 1 1 NULL NULL
304
3 1 6 2 1 1 NULL NULL
305
3 3 NULL NULL NULL NULL NULL NULL
306
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
310
ON t3.a=1 AND t2.b=t4.b;
314
3 3 NULL NULL NULL NULL
315
5 3 NULL NULL NULL NULL
316
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
317
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
321
ON t3.a=1 AND t2.b=t4.b,
328
ON t7.b=t8.b AND t6.b < 10
330
ON t6.b >= 2 AND t5.b=t7.b;
331
a b a b a b a b a b a b a b
332
4 2 1 2 3 2 2 2 3 2 2 2 0 2
333
4 2 1 2 4 2 2 2 3 2 2 2 0 2
334
4 2 1 2 3 2 2 2 6 2 2 2 0 2
335
4 2 1 2 4 2 2 2 6 2 2 2 0 2
336
4 2 1 2 3 2 2 2 3 2 2 2 1 2
337
4 2 1 2 4 2 2 2 3 2 2 2 1 2
338
4 2 1 2 3 2 2 2 6 2 2 2 1 2
339
4 2 1 2 4 2 2 2 6 2 2 2 1 2
340
4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
341
4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
342
4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
343
4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
344
4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
345
4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
346
3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
347
5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
348
3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
349
5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
350
3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
351
5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
352
3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
353
5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
354
3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
355
5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
356
3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
357
5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
358
3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
359
5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
360
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
361
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
365
ON t3.a=1 AND t2.b=t4.b,
372
ON t7.b=t8.b AND t6.b < 10
374
ON t6.b >= 2 AND t5.b=t7.b
376
(t6.a < 6 OR t6.c IS NULL);
377
a b a b a b a b a b a b a b
378
4 2 1 2 3 2 2 2 3 2 2 2 0 2
379
4 2 1 2 4 2 2 2 3 2 2 2 0 2
380
4 2 1 2 3 2 2 2 3 2 2 2 1 2
381
4 2 1 2 4 2 2 2 3 2 2 2 1 2
382
4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
383
4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
384
4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
385
4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
386
5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
387
5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
388
5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
389
5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
396
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
397
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
404
ON t3.a=1 AND t2.b=t4.b,
411
ON t7.b=t8.b AND t6.b < 10
413
ON t6.b >= 2 AND t5.b=t7.b
415
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
416
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
418
a b a b a b a b a b a b a b a b
419
3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2
420
3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2
421
3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2
422
3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2
423
3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2
424
3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2
425
3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2
426
3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2
427
1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
428
3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
429
1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
430
3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
431
1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
432
3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
433
1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
434
3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
435
1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
436
3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
437
1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
438
3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
439
1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
440
3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
441
1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
442
3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
443
1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
444
3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
445
1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
446
3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
447
1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
448
3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
449
1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
450
3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
451
1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
452
3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
453
1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
454
3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
455
1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
456
3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
457
1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
458
3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
459
1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
460
3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
461
1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
462
3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
463
1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
464
3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
465
1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
466
3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
467
2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
468
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
469
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
476
ON t3.a=1 AND t2.b=t4.b,
483
ON t7.b=t8.b AND t6.b < 10
485
ON t6.b >= 2 AND t5.b=t7.b
487
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
488
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
490
WHERE (t2.a >= 4 OR t2.c IS NULL);
491
a b a b a b a b a b a b a b a b
492
3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2
493
3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2
494
3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2
495
3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2
496
3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2
497
3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2
498
3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2
499
3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2
500
1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
501
3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
502
1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
503
3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
504
1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
505
3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
506
1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
507
3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
508
1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
509
3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
510
1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
511
3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
512
1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
513
3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
514
1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
515
3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
516
1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
517
3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
518
1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
519
3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
520
1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
521
3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
522
1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
523
3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
524
1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
525
3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
526
2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
534
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
535
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
542
ON t3.a=1 AND t2.b=t4.b,
549
ON t7.b=t8.b AND t6.b < 10
551
ON t6.b >= 2 AND t5.b=t7.b
553
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
554
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
558
(t2.a >= 4 OR t2.c IS NULL);
559
id select_type table type possible_keys key key_len ref rows filtered Extra
560
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
561
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
562
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
563
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
564
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
565
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
566
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
567
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
568
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
570
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
571
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
572
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
579
ON t3.a=1 AND t2.b=t4.b,
586
ON t7.b=t8.b AND t6.b < 10
588
ON t6.b >= 2 AND t5.b=t7.b
590
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
591
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
595
(t2.a >= 4 OR t2.c IS NULL);
596
a b a b a b a b a b a b a b a b a b
597
1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2
598
1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2
599
1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2
600
1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2
601
1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2
602
1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2
603
1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2
604
1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2
605
1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL
606
1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL
607
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL
608
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL
609
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL
610
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL
611
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2
612
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2
613
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2
614
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2
615
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL
616
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL
617
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL
618
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
620
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
621
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
628
ON t3.a=1 AND t2.b=t4.b,
635
ON t7.b=t8.b AND t6.b < 10
637
ON t6.b >= 2 AND t5.b=t7.b
639
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
640
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
645
(t2.a >= 4 OR t2.c IS NULL) AND
646
(t3.a < 5 OR t3.c IS NULL) AND
647
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
648
(t5.a >=2 OR t5.c IS NULL) AND
649
(t6.a >=4 OR t6.c IS NULL) AND
650
(t7.a <= 2 OR t7.c IS NULL) AND
651
(t8.a < 1 OR t8.c IS NULL) AND
652
(t8.b=t9.b OR t8.c IS NULL) AND
654
id select_type table type possible_keys key key_len ref rows filtered Extra
655
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
656
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
657
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
658
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
659
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
660
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
661
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
662
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
663
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
664
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
666
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t9`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
673
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
674
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
681
ON t3.a=1 AND t2.b=t4.b,
688
ON t7.b=t8.b AND t6.b < 10
690
ON t6.b >= 2 AND t5.b=t7.b
692
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
693
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
698
(t2.a >= 4 OR t2.c IS NULL) AND
699
(t3.a < 5 OR t3.c IS NULL) AND
700
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
701
(t5.a >=2 OR t5.c IS NULL) AND
702
(t6.a >=4 OR t6.c IS NULL) AND
703
(t7.a <= 2 OR t7.c IS NULL) AND
704
(t8.a < 1 OR t8.c IS NULL) AND
705
(t8.b=t9.b OR t8.c IS NULL) AND
707
a b a b a b a b a b a b a b a b a b a b
708
1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2
709
1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2
710
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1
711
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1
712
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2
713
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2
714
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
715
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
716
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2
717
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2
718
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2
719
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1
720
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2
721
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1
722
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2
723
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1
724
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2
742
SELECT t2.a,t2.b,t3.a,t3.b
752
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b
767
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b
782
SELECT t3.a,t3.b,t4.a,t4.b
789
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
793
ON t3.a=1 AND t2.b=t4.b;
797
3 3 NULL NULL NULL NULL
798
5 3 NULL NULL NULL NULL
799
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
803
ON t3.a=1 AND t2.b=t4.b
810
1 3 3 3 NULL NULL NULL NULL
811
2 2 3 3 NULL NULL NULL NULL
812
1 3 5 3 NULL NULL NULL NULL
813
2 2 5 3 NULL NULL NULL NULL
814
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
818
ON t3.a=1 AND t2.b=t4.b
825
1 3 3 3 NULL NULL NULL NULL
826
2 2 3 3 NULL NULL NULL NULL
827
1 3 5 3 NULL NULL NULL NULL
828
2 2 5 3 NULL NULL NULL NULL
829
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
833
ON t3.a=1 AND t2.b=t4.b
840
1 3 3 3 NULL NULL NULL NULL
841
2 2 3 3 NULL NULL NULL NULL
842
1 3 5 3 NULL NULL NULL NULL
843
2 2 5 3 NULL NULL NULL NULL
845
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
849
ON t3.a=1 AND t2.b=t4.b
851
id select_type table type possible_keys key key_len ref rows filtered Extra
852
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
853
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
854
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
855
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
857
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
858
INSERT INTO t2 VALUES (-1,9,0), (-3,10,0), (-2,8,0), (-4,11,0), (-5,15,0);
859
CREATE INDEX idx_b ON t2(b);
861
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
865
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0;
866
id select_type table type possible_keys key key_len ref rows filtered Extra
867
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
868
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
869
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
870
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
872
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`a` > 0) and (`test`.`t3`.`b` is not null))) where 1
873
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
877
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0;
888
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
889
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
896
ON t3.a=1 AND t2.b=t4.b AND t2.a>0,
903
ON t7.b=t8.b AND t6.b < 10
905
ON t6.b >= 2 AND t5.b=t7.b
907
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
908
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
913
(t2.a >= 4 OR t2.c IS NULL) AND
914
(t3.a < 5 OR t3.c IS NULL) AND
915
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
916
(t5.a >=2 OR t5.c IS NULL) AND
917
(t6.a >=4 OR t6.c IS NULL) AND
918
(t7.a <= 2 OR t7.c IS NULL) AND
919
(t8.a < 1 OR t8.c IS NULL) AND
920
(t8.b=t9.b OR t8.c IS NULL) AND
922
id select_type table type possible_keys key key_len ref rows filtered Extra
923
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
924
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
925
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
926
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
927
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
928
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
929
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join)
930
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
931
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
932
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
934
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` > 0) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t9`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
935
INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0);
936
INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0);
937
CREATE INDEX idx_b ON t4(b);
938
CREATE INDEX idx_b ON t5(b);
940
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
941
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
948
ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0,
955
ON t7.b=t8.b AND t6.b < 10
957
ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0
959
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
960
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
965
(t2.a >= 4 OR t2.c IS NULL) AND
966
(t3.a < 5 OR t3.c IS NULL) AND
967
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
968
(t5.a >=2 OR t5.c IS NULL) AND
969
(t6.a >=4 OR t6.c IS NULL) AND
970
(t7.a <= 2 OR t7.c IS NULL) AND
971
(t8.a < 1 OR t8.c IS NULL) AND
972
(t8.b=t9.b OR t8.c IS NULL) AND
974
id select_type table type possible_keys key key_len ref rows filtered Extra
975
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
976
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
977
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
978
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join)
979
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
980
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
981
1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join)
982
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
983
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
984
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
986
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t9`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`)))
987
INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0);
988
CREATE INDEX idx_b ON t8(b);
990
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
991
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
998
ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0,
1005
ON t7.b=t8.b AND t6.b < 10 AND t8.a>=0
1007
ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0
1009
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
1010
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
1015
(t2.a >= 4 OR t2.c IS NULL) AND
1016
(t3.a < 5 OR t3.c IS NULL) AND
1017
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
1018
(t5.a >=2 OR t5.c IS NULL) AND
1019
(t6.a >=4 OR t6.c IS NULL) AND
1020
(t7.a <= 2 OR t7.c IS NULL) AND
1021
(t8.a < 1 OR t8.c IS NULL) AND
1022
(t8.b=t9.b OR t8.c IS NULL) AND
1024
id select_type table type possible_keys key key_len ref rows filtered Extra
1025
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1026
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1027
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1028
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join)
1029
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1030
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1031
1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join)
1032
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1033
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1034
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1036
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t8`.`a` >= 0) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t9`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`)))
1037
INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0);
1038
CREATE INDEX idx_b ON t1(b);
1039
CREATE INDEX idx_a ON t0(a);
1041
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
1042
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
1049
ON t3.a=1 AND t2.b=t4.b,
1056
ON t7.b=t8.b AND t6.b < 10
1058
ON t6.b >= 2 AND t5.b=t7.b
1060
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
1061
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
1062
(t1.a != 2) AND t1.a>0,
1066
(t2.a >= 4 OR t2.c IS NULL) AND
1067
(t3.a < 5 OR t3.c IS NULL) AND
1068
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
1069
(t5.a >=2 OR t5.c IS NULL) AND
1070
(t6.a >=4 OR t6.c IS NULL) AND
1071
(t7.a <= 2 OR t7.c IS NULL) AND
1072
(t8.a < 1 OR t8.c IS NULL) AND
1073
(t8.b=t9.b OR t8.c IS NULL) AND
1075
id select_type table type possible_keys key key_len ref rows filtered Extra
1076
1 SIMPLE t0 ref idx_a idx_a 5 const 1 100.00 Using where
1077
1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1078
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1079
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join)
1080
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1081
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1082
1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join)
1083
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1084
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1085
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1087
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2) and (`test`.`t1`.`a` > 0))) join `test`.`t9` where ((`test`.`t0`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t9`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`)))
1088
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
1089
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
1096
ON t3.a=1 AND t2.b=t4.b,
1103
ON t7.b=t8.b AND t6.b < 10
1105
ON t6.b >= 2 AND t5.b=t7.b
1107
ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND
1108
(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND
1109
(t1.a != 2) AND t1.a>0,
1113
(t2.a >= 4 OR t2.c IS NULL) AND
1114
(t3.a < 5 OR t3.c IS NULL) AND
1115
(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND
1116
(t5.a >=2 OR t5.c IS NULL) AND
1117
(t6.a >=4 OR t6.c IS NULL) AND
1118
(t7.a <= 2 OR t7.c IS NULL) AND
1119
(t8.a < 1 OR t8.c IS NULL) AND
1120
(t8.b=t9.b OR t8.c IS NULL) AND
1122
a b a b a b a b a b a b a b a b a b a b
1123
1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2
1124
1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2
1125
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1
1126
1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2
1127
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1
1128
1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2
1129
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
1130
1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2
1131
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1
1132
1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2
1133
1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2
1134
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1
1135
1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2
1136
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1
1137
1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2
1138
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1
1139
1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2
1156
SELECT t2.a,t2.b,t3.a,t3.b
1157
FROM t2 LEFT JOIN t3 ON t2.b=t3.b
1158
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);
1163
SELECT t2.a,t2.b,t3.a,t3.b
1164
FROM t2 LEFT JOIN (t3) ON t2.b=t3.b
1165
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);
1171
CHANGE COLUMN a a1 int,
1172
CHANGE COLUMN c c1 int;
1173
SELECT t2.a,t2.b,t3.a1,t3.b
1174
FROM t2 LEFT JOIN t3 ON t2.b=t3.b
1175
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
1180
SELECT t2.a,t2.b,t3.a1,t3.b
1181
FROM t2 NATURAL LEFT JOIN t3
1182
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
1187
DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;
1188
CREATE TABLE t1 (a int);
1189
CREATE TABLE t2 (a int);
1190
CREATE TABLE t3 (a int);
1191
INSERT INTO t1 VALUES (1);
1192
INSERT INTO t2 VALUES (2);
1193
INSERT INTO t3 VALUES (2);
1194
INSERT INTO t1 VALUES (2);
1195
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a;
1199
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1203
DELETE FROM t1 WHERE a=2;
1204
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1208
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;
1211
DROP TABLE t1,t2,t3;
1212
CREATE TABLE t1(a int, key (a));
1213
CREATE TABLE t2(b int, key (b));
1214
CREATE TABLE t3(c int, key (c));
1215
INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
1216
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
1217
INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
1218
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
1219
INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5);
1220
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c;
1221
id select_type table type possible_keys key key_len ref rows Extra
1222
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
1223
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
1224
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
1225
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1226
id select_type table type possible_keys key key_len ref rows Extra
1227
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
1228
1 SIMPLE t3 index c c 5 NULL 6 Using where; Using index
1229
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
1230
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1296
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1297
id select_type table type possible_keys key key_len ref rows Extra
1298
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
1299
1 SIMPLE t3 index c c 5 NULL 0 Using where; Using index
1300
1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
1301
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
1324
DROP TABLE t1,t2,t3;
1325
CREATE TABLE t1 (c11 int);
1326
CREATE TABLE t2 (c21 int);
1327
CREATE TABLE t3 (c31 int);
1328
INSERT INTO t1 VALUES (4), (5);
1329
SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;
1333
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;
1334
id select_type table type possible_keys key key_len ref rows Extra
1335
1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
1336
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1337
SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
1341
EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
1342
id select_type table type possible_keys key key_len ref rows Extra
1343
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1344
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c11 0 Using where; Using join buffer (flat, BNLH join)
1345
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (incremental, BNL join)
1346
DROP TABLE t1,t2,t3;
1347
CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL);
1348
INSERT INTO t1 VALUES (23, 2340), (26, 9900);
1349
CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2));
1350
INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr');
1351
create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL);
1352
INSERT INTO t3 VALUES (3,23), (6,26);
1353
CREATE TABLE t4 (groupid int(12));
1354
INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6);
1356
(SELECT DISTINCT gl.groupid, gp.price
1359
(t3 g INNER JOIN t2 p ON g.goodsid = p.goods
1360
INNER JOIN t1 gp ON p.goods = gp.goods)
1361
ON gl.groupid = g.groupid and p.shop = 'fr') t;
1370
SELECT g.groupid groupid, p.goods goods,
1371
p.name name, p.shop shop,
1373
FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods
1374
INNER JOIN t1 gp on p.goods = gp.goods;
1376
SELECT DISTINCT g.groupid, fr.price
1379
v1 fr on g.groupid = fr.groupid and fr.shop = 'fr';
1389
(SELECT DISTINCT g.groupid, fr.price
1392
v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t;
1401
DROP TABLE t1,t2,t3,t4;
1402
CREATE TABLE t1(a int);
1403
CREATE TABLE t2(b int);
1404
CREATE TABLE t3(c int, d int);
1405
CREATE TABLE t4(d int);
1406
CREATE TABLE t5(e int, f int);
1407
CREATE TABLE t6(f int);
1409
SELECT e FROM t5 JOIN t6 ON t5.e=t6.f;
1411
SELECT e FROM t5 NATURAL JOIN t6;
1412
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
1414
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
1415
ERROR 42S22: Unknown column 't1.x' in 'field list'
1416
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
1418
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
1419
ERROR 42S22: Unknown column 't1.x' in 'field list'
1420
SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
1422
SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
1423
ERROR 42S22: Unknown column 'v1.x' in 'field list'
1424
SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
1426
SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
1427
ERROR 42S22: Unknown column 'v2.x' in 'field list'
1429
DROP TABLE t1, t2, t3, t4, t5, t6;
1430
create table t1 (id1 int(11) not null);
1431
insert into t1 values (1),(2);
1432
create table t2 (id2 int(11) not null);
1433
insert into t2 values (1),(2),(3),(4);
1434
create table t3 (id3 char(16) not null);
1435
insert into t3 values ('100');
1436
create table t4 (id2 int(11) not null, id3 char(16));
1437
create table t5 (id1 int(11) not null, key (id1));
1438
insert into t5 values (1),(2),(1);
1440
select t4.id3 from t4 join t2 on t4.id2 = t2.id2;
1441
select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3);
1446
drop table t1, t2, t3, t4, t5;
1447
create table t0 (a int);
1448
insert into t0 values (0),(1),(2),(3);
1449
create table t1(a int);
1450
insert into t1 select A.a + 10*(B.a) from t0 A, t0 B;
1451
create table t2 (a int, b int);
1452
insert into t2 values (1,1), (2,2), (3,3);
1453
create table t3(a int, b int, filler char(200), key(a));
1454
insert into t3 select a,a,'filler' from t1;
1455
insert into t3 select a,a,'filler' from t1;
1456
create table t4 like t3;
1457
insert into t4 select * from t3;
1458
insert into t4 select * from t3;
1459
create table t5 like t4;
1460
insert into t5 select * from t4;
1461
insert into t5 select * from t4;
1462
create table t6 like t5;
1463
insert into t6 select * from t5;
1464
insert into t6 select * from t5;
1465
create table t7 like t6;
1466
insert into t7 select * from t6;
1467
insert into t7 select * from t6;
1468
explain select * from t4 join
1469
t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b;
1470
id select_type table type possible_keys key key_len ref rows Extra
1471
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1472
1 SIMPLE t3 ref a a 5 test.t2.b X Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1473
1 SIMPLE t5 ref a a 5 test.t3.b X Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1474
1 SIMPLE t4 ref a a 5 test.t3.b X Using index condition(BKA); Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1475
explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b
1476
join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b;
1477
id select_type table type possible_keys key key_len ref rows Extra
1478
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1479
1 SIMPLE t3 ref a a 5 test.t2.b X Using index condition(BKA); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1480
1 SIMPLE t4 ref a a 5 test.t3.b X Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1481
1 SIMPLE t6 ref a a 5 test.t4.b X Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1482
1 SIMPLE t5 ref a a 5 test.t2.b X Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1483
1 SIMPLE t7 ref a a 5 test.t5.b X Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1484
explain select * from t2 left join
1485
(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b
1486
join t5 on t5.a=t3.b) on t3.a=t2.b;
1487
id select_type table type possible_keys key key_len ref rows Extra
1488
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1489
1 SIMPLE t3 ref a a 5 test.t2.b X Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1490
1 SIMPLE t5 ref a a 5 test.t3.b X Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1491
1 SIMPLE t4 ref a a 5 test.t5.a X Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1492
1 SIMPLE t6 ref a a 5 test.t4.b X Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1493
drop table t0, t1, t2, t3, t4, t5, t6, t7;
1494
create table t1 (a int);
1495
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1496
create table t2 (a int, filler char(100), key(a));
1497
insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B;
1498
create table t3 like t2;
1499
insert into t3 select * from t2;
1500
explain select * from t1 left join
1501
(t2 left join t3 on (t2.a = t3.a))
1503
id select_type table type possible_keys key key_len ref rows Extra
1504
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
1505
1 SIMPLE t2 ref a a 5 test.t1.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1506
1 SIMPLE t3 ref a a 5 test.t1.a 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1507
drop table t1, t2, t3;
1508
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10));
1509
CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10));
1510
CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY,
1513
INSERT INTO t1 VALUES (1, 'A'), (3, 'C');
1514
INSERT INTO t2 VALUES (1, 'A'), (3, 'C');
1515
INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3);
1516
SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1)
1517
ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id)
1518
LEFT JOIN t2 ON (t3.pid=t2.pid)
1520
id type cid id pid id type pid type
1521
1 A NULL NULL NULL NULL NULL NULL NULL
1523
SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B';
1524
SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id
1525
LEFT JOIN t2 ON v1.pid=t2.pid
1527
id type cid id pid pid type
1528
1 A NULL NULL NULL NULL NULL
1530
DROP TABLE t1,t2,t3;
1531
CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int);
1532
CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int);
1533
CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int);
1534
CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int);
1535
CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int);
1536
SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa
1537
FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1
1539
(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1)
1540
ON t3.id2 IS NOT NULL
1544
"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa
1545
FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1
1547
(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1)
1548
ON t3.id2 IS NOT NULL
1558
INSERT INTO t1 VALUES (1,1), (2,1), (3,2);
1559
INSERT INTO t2 VALUES (2,1), (3,2), (4,3);
1560
INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL);
1561
INSERT INTO t4 VALUES (1,1), (2,1), (3,3);
1562
INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3);
1579
SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa
1580
FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1
1582
(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1)
1583
ON t3.id2 IS NOT NULL
1588
DROP TABLE t1,t2,t3,t4,t5;
1590
id int NOT NULL PRIMARY KEY,
1591
ct int DEFAULT NULL,
1592
pc int DEFAULT NULL,
1596
INSERT INTO t1 VALUES
1597
(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL);
1599
id int NOT NULL PRIMARY KEY,
1601
nm varchar(255) NOT NULL,
1604
INSERT INTO t2 VALUES
1605
(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand');
1607
id int NOT NULL PRIMARY KEY,
1614
id int NOT NULL PRIMARY KEY,
1615
nm varchar(255) NOT NULL
1617
INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique');
1620
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id
1626
(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id
1627
LEFT JOIN t4 ON t2.sr=t4.id
1631
DROP TABLE t1,t2,t3,t4;
1632
CREATE TABLE t1 (a INT, b INT);
1633
CREATE TABLE t2 (a INT);
1634
CREATE TABLE t3 (a INT, c INT);
1635
CREATE TABLE t4 (a INT, c INT);
1636
CREATE TABLE t5 (a INT, c INT);
1637
SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
1638
LEFT JOIN t5 USING (a)) USING (a);
1640
SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
1641
LEFT JOIN t5 USING (a)) USING (a);
1642
ERROR 23000: Column 'c' in field list is ambiguous
1643
SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a)
1644
JOIN t5 USING (a)) USING (a);
1646
SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a)
1647
JOIN t5 USING (a)) USING (a);
1648
ERROR 23000: Column 'c' in field list is ambiguous
1649
DROP TABLE t1,t2,t3,t4,t5;
1650
CREATE TABLE t1 (a INT, b INT);
1651
CREATE TABLE t2 (a INT, b INT);
1652
CREATE TABLE t3 (a INT, b INT);
1653
INSERT INTO t1 VALUES (1,1);
1654
INSERT INTO t2 VALUES (1,1);
1655
INSERT INTO t3 VALUES (1,1);
1656
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
1657
ERROR 23000: Column 'a' in from clause is ambiguous
1658
DROP TABLE t1,t2,t3;
1660
carrier char(2) default NULL,
1661
id int NOT NULL auto_increment PRIMARY KEY
1663
INSERT INTO t1 VALUES
1664
('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
1665
('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
1666
('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
1667
('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
1668
('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
1669
('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
1670
('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
1671
('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
1672
('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
1674
scan_date date default NULL,
1675
package_id int default NULL,
1676
INDEX scan_date(scan_date),
1677
INDEX package_id(package_id)
1679
INSERT INTO t2 VALUES
1680
('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
1681
('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
1682
('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
1683
('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
1684
('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
1685
('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
1686
('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
1687
('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
1688
('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
1689
('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
1690
('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
1691
('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
1692
('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
1693
('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
1694
('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
1696
package_id int default NULL,
1697
INDEX package_id(package_id)
1699
INSERT INTO t3 VALUES
1700
(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
1701
(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
1702
(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
1703
(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
1704
(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
1705
(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
1706
(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
1707
(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
1708
(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
1709
(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
1710
(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
1711
(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
1712
(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
1713
(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
1714
(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
1715
(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
1716
(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
1717
(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
1718
(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
1719
(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
1720
(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
1721
(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
1722
(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
1724
carrier char(2) NOT NULL default '' PRIMARY KEY,
1725
id int(11) default NULL,
1728
INSERT INTO t4 VALUES
1729
('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
1731
carrier_id int default NULL,
1732
INDEX carrier_id(carrier_id)
1734
INSERT INTO t5 VALUES
1735
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1736
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1737
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1738
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1739
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
1740
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
1741
(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
1742
(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
1744
FROM((t2 JOIN t1 ON t2.package_id = t1.id)
1745
JOIN t3 ON t3.package_id = t1.id);
1750
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
1751
JOIN t3 ON t3.package_id = t1.id)
1753
(t5 JOIN t4 ON t5.carrier_id = t4.id)
1754
ON t4.carrier = t1.carrier;
1755
id select_type table type possible_keys key key_len ref rows Extra
1756
1 SIMPLE t2 index package_id package_id 5 NULL 45 Using where; Using index
1757
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1758
1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1 Using where
1759
1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
1760
1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index
1762
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
1763
JOIN t3 ON t3.package_id = t1.id)
1765
(t5 JOIN t4 ON t5.carrier_id = t4.id)
1766
ON t4.carrier = t1.carrier;
1769
DROP TABLE t1,t2,t3,t4,t5;
1771
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
1776
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
1781
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
1785
INSERT INTO t1 VALUES
1786
(1,2), (2,7), (3,5), (4,7), (5,5), (6,NULL), (7,NULL), (8,9);
1787
INSERT INTO t2 VALUES
1788
(1,NULL), (4,2), (5,2), (3,4), (2,8);
1789
INSERT INTO t3 VALUES
1790
(1,9), (2,2), (3,5), (4,2), (5,7), (6,0), (7,5);
1791
SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a
1792
FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a;
1798
2 7 NULL NULL NULL NULL
1799
3 5 NULL NULL NULL NULL
1800
4 7 NULL NULL NULL NULL
1801
5 5 NULL NULL NULL NULL
1802
6 NULL NULL NULL NULL NULL
1803
7 NULL NULL NULL NULL NULL
1804
8 9 NULL NULL NULL NULL
1805
SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a
1806
FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a
1807
WHERE t2.pk IS NULL;
1809
2 7 NULL NULL NULL NULL
1810
3 5 NULL NULL NULL NULL
1811
4 7 NULL NULL NULL NULL
1812
5 5 NULL NULL NULL NULL
1813
6 NULL NULL NULL NULL NULL
1814
7 NULL NULL NULL NULL NULL
1815
8 9 NULL NULL NULL NULL
1816
SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a
1817
FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a
1818
WHERE t3.pk IS NULL;
1820
2 7 NULL NULL NULL NULL
1821
3 5 NULL NULL NULL NULL
1822
4 7 NULL NULL NULL NULL
1823
5 5 NULL NULL NULL NULL
1824
6 NULL NULL NULL NULL NULL
1825
7 NULL NULL NULL NULL NULL
1826
8 9 NULL NULL NULL NULL
1827
DROP TABLE t1, t2, t3;
1828
CREATE TABLE t1 (a int NOT NULL );
1829
INSERT INTO t1 VALUES (9), (9);
1830
CREATE TABLE t2 (a int NOT NULL );
1831
INSERT INTO t2 VALUES (9);
1832
CREATE TABLE t3 (a int NOT NULL, b int);
1833
INSERT INTO t3 VALUES (19,9);
1834
CREATE TABLE t4 (b int) ;
1835
SELECT * FROM t1 LEFT JOIN
1836
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
1841
SELECT * FROM t1 LEFT JOIN
1842
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
1847
SELECT * FROM t1 LEFT JOIN
1848
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
1851
id select_type table type possible_keys key key_len ref rows filtered Extra
1852
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1853
1 SIMPLE t2 hash_ALL NULL #hash#$hj 4 test.t1.a 1 100.00 Using where; Using join buffer (flat, BNLH join)
1854
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1 100.00 Using where; Not exists; Using join buffer (incremental, BNLH join)
1855
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t3.a 0 0.00 Using where; Using join buffer (incremental, BNLH join)
1857
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t1`.`a`)) left join `test`.`t4` on(((`test`.`t4`.`b` = `test`.`t3`.`a`) and (`test`.`t3`.`a` is not null)))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where isnull(`test`.`t3`.`a`)
1858
DROP TABLE t1,t2,t3,t4;
1859
SET optimizer_switch=@save_optimizer_switch;
1862
# MDEV-621: LP:693329 - Assertion `!is_interleave_error' failed on low optimizer_search_depth
1864
set @tmp_mdev621= @@optimizer_search_depth;
1865
SET SESSION optimizer_search_depth = 4;
1866
CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ;
1867
INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0);
1868
CREATE TABLE t2 (f1 int) ;
1869
CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ;
1870
CREATE TABLE t4 (f5 int) ;
1871
CREATE TABLE t5 (f2 int) ;
1872
SELECT alias2.f4 FROM t1 AS alias1
1873
LEFT JOIN t1 AS alias2
1874
LEFT JOIN t2 AS alias3
1875
LEFT JOIN t3 AS alias4 ON alias3.f1 = alias4.f3
1877
LEFT JOIN t4 AS alias5
1878
JOIN t5 ON alias5.f5
1879
ON alias2.f3 ON alias1.f2;
1883
DROP TABLE t1,t2,t3,t4,t5;
1884
set optimizer_search_depth= @tmp_mdev621;
1885
CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
1886
CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
1887
CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
1888
CREATE TABLE t8 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
1889
INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0);
1890
INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0);
1891
INSERT INTO t7 VALUES (1,1,0), (2,2,0);
1892
INSERT INTO t8 VALUES (0,2,0), (1,2,0);
1893
INSERT INTO t6 VALUES (-1,12,0), (-3,13,0), (-6,11,0), (-4,14,0);
1894
INSERT INTO t7 VALUES (-1,11,0), (-2,12,0), (-3,13,0), (-4,14,0), (-5,15,0);
1895
INSERT INTO t8 VALUES (-3,13,0), (-1,12,0), (-2,14,0), (-5,15,0), (-4,16,0);
1897
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1904
ON t7.b=t8.b AND t6.b < 10
1906
ON t6.b >= 2 AND t5.b=t7.b AND
1907
(t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0;
1908
id select_type table type possible_keys key key_len ref rows Extra
1909
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
1910
1 SIMPLE t7 ref PRIMARY,b_i b_i 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1911
1 SIMPLE t6 ALL PRIMARY,b_i NULL NULL NULL 7 Using where; Using join buffer (incremental, BNL join)
1912
1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1913
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1920
ON t7.b=t8.b AND t6.b < 10
1922
ON t6.b >= 2 AND t5.b=t7.b AND
1923
(t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0;
1927
1 1 1 2 1 1 NULL NULL
1928
1 1 3 2 1 1 NULL NULL
1929
3 3 NULL NULL NULL NULL NULL NULL
1934
INSERT INTO t5 VALUES (1,3,0), (3,2,0);
1935
INSERT INTO t6 VALUES (3,3,0);
1936
INSERT INTO t7 VALUES (1,2,0);
1937
INSERT INTO t8 VALUES (1,1,0);
1939
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1941
(t6 LEFT JOIN t7 ON t7.a=1, t8)
1943
id select_type table type possible_keys key key_len ref rows Extra
1944
1 SIMPLE t5 ALL NULL NULL NULL NULL 2
1945
1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
1946
1 SIMPLE t7 const PRIMARY PRIMARY 4 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1947
1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)
1948
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1950
(t6 LEFT JOIN t7 ON t7.a=1, t8)
1953
1 3 NULL NULL NULL NULL NULL NULL
1954
3 2 NULL NULL NULL NULL NULL NULL
1956
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1958
(t6 LEFT JOIN t7 ON t7.b=2, t8)
1960
id select_type table type possible_keys key key_len ref rows Extra
1961
1 SIMPLE t5 ALL NULL NULL NULL NULL 2
1962
1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
1963
1 SIMPLE t7 ref b_i b_i 5 const 0 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1964
1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)
1965
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1967
(t6 LEFT JOIN t7 ON t7.b=2, t8)
1970
1 3 NULL NULL NULL NULL NULL NULL
1971
3 2 NULL NULL NULL NULL NULL NULL
1973
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1975
(t8, t6 LEFT JOIN t7 ON t7.a=1)
1977
id select_type table type possible_keys key key_len ref rows Extra
1978
1 SIMPLE t5 ALL NULL NULL NULL NULL 2
1979
1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
1980
1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (incremental, BNL join)
1981
1 SIMPLE t7 const PRIMARY PRIMARY 4 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1982
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
1984
(t8, t6 LEFT JOIN t7 ON t7.a=1)
1987
1 3 NULL NULL NULL NULL NULL NULL
1988
3 2 NULL NULL NULL NULL NULL NULL
1989
DROP TABLE t5,t6,t7,t8;
1990
set join_cache_level=default;
1991
show variables like 'join_cache_level';
1994
set @@optimizer_switch=@save_optimizer_switch_jcl6;
1995
set @optimizer_switch_for_join_nested_test=NULL;
1996
set @join_cache_level_for_join_nested_test=NULL;