You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDEV-37389 Hint NO_MERGE(@qb_name) is accepted but has no effect
Allows [NO_]MERGE(@qb_name) and [NO_]MERGE() to apply to all tables
in a target named query block and all tables in the current query
block, respectively.
Repairs a bug when fixing hints for derived tables that prevented
derived tables from being linked with a query block's hints in the
case that no derived tables were explicitly specified in the query.
3 DERIVED salaries ALL NULL NULL NULL NULL 2 100.00
496
+
2 DERIVED employees ALL NULL NULL NULL NULL 2 100.00
497
+
Warnings:
498
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `e`.`emp_name` AS `emp_name`,`s`.`salary` AS `salary` from (/* select#2 */ select `test`.`employees`.`emp_id` AS `emp_id`,`test`.`employees`.`emp_name` AS `emp_name`,`test`.`employees`.`department` AS `department` from `test`.`employees`) `e` join (/* select#3 */ select `test`.`salaries`.`emp_id` AS `emp_id`,`test`.`salaries`.`salary` AS `salary` from `test`.`salaries`) `s` where `s`.`emp_id` = `e`.`emp_id`
3 DERIVED salaries ALL NULL NULL NULL NULL 2 100.00
505
+
2 DERIVED employees ALL NULL NULL NULL NULL 2 100.00
506
+
Warnings:
507
+
Note 1003 /* select#1 */ select /*+ QB_NAME(`foo`) NO_MERGE(@`foo`) */ `e`.`emp_name` AS `emp_name`,`s`.`salary` AS `salary` from (/* select#2 */ select `test`.`employees`.`emp_id` AS `emp_id`,`test`.`employees`.`emp_name` AS `emp_name`,`test`.`employees`.`department` AS `department` from `test`.`employees`) `e` join (/* select#3 */ select `test`.`salaries`.`emp_id` AS `emp_id`,`test`.`salaries`.`salary` AS `salary` from `test`.`salaries`) `s` where `s`.`emp_id` = `e`.`emp_id`
508
+
EXPLAIN EXTENDED
509
+
select /*+ NO_MERGE() */ emp_id from (
510
+
select /*+ NO_MERGE() */ emp_id from (
511
+
select /*+ NO_MERGE() */ emp_id from (
512
+
select /*+ NO_MERGE() */ emp_id from (
513
+
select emp_id from employees) dt) du) dv) dw;
514
+
id select_type table type possible_keys key key_len ref rows filtered Extra
515
+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
516
+
2 DERIVED <derived3> ALL NULL NULL NULL NULL 2 100.00
517
+
3 DERIVED <derived4> ALL NULL NULL NULL NULL 2 100.00
518
+
4 DERIVED <derived5> ALL NULL NULL NULL NULL 2 100.00
519
+
5 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
520
+
Warnings:
521
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#4`) NO_MERGE(@`select#3`) NO_MERGE(@`select#2`) NO_MERGE(@`select#1`) */ `dw`.`emp_id` AS `emp_id` from (/* select#2 */ select `dv`.`emp_id` AS `emp_id` from (/* select#3 */ select `du`.`emp_id` AS `emp_id` from (/* select#4 */ select `dt`.`emp_id` AS `emp_id` from (/* select#5 */ select `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dt`) `du`) `dv`) `dw`
522
+
EXPLAIN EXTENDED
523
+
select /*+ NO_MERGE(@qb4) */ emp_id from (
524
+
select /*+ QB_NAME(qb2) */ emp_id from (
525
+
select /*+ QB_NAME(qb3) */ emp_id from (
526
+
select /*+ QB_NAME(qb4) */ emp_id from (
527
+
select emp_id from employees) dt) du) dv) dw;
528
+
id select_type table type possible_keys key key_len ref rows filtered Extra
529
+
1 PRIMARY <derived5> ALL NULL NULL NULL NULL 2 100.00
530
+
5 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
531
+
Warnings:
532
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`qb4`) */ `dt`.`emp_id` AS `emp_id` from (/* select#5 */ select `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dt`
533
+
EXPLAIN EXTENDED
534
+
select /*+ NO_MERGE(@qb3) */ emp_id from (
535
+
select /*+ QB_NAME(qb2) */ emp_id from (
536
+
select /*+ QB_NAME(qb3) */ emp_id from (
537
+
select /*+ QB_NAME(qb4) */ emp_id from (
538
+
select emp_id from employees) dt) du) dv) dw;
539
+
id select_type table type possible_keys key key_len ref rows filtered Extra
540
+
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 2 100.00
541
+
4 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
542
+
Warnings:
543
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`qb3`) */ `du`.`emp_id` AS `emp_id` from (/* select#4 */ select /*+ QB_NAME(`qb4`) */ `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `du`
544
+
EXPLAIN EXTENDED
545
+
select /*+ NO_MERGE(@qb2) */ emp_id from (
546
+
select /*+ QB_NAME(qb2) */ emp_id from (
547
+
select /*+ QB_NAME(qb3) */ emp_id from (
548
+
select /*+ QB_NAME(qb4) */ emp_id from (
549
+
select emp_id from employees) dt) du) dv) dw;
550
+
id select_type table type possible_keys key key_len ref rows filtered Extra
551
+
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 100.00
552
+
3 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
553
+
Warnings:
554
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`qb2`) */ `dv`.`emp_id` AS `emp_id` from (/* select#3 */ select /*+ QB_NAME(`qb3`) */ `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dv`
555
+
EXPLAIN EXTENDED
556
+
select /*+ NO_MERGE(@qb2) NO_MERGE(@qb4) */ emp_id from (
557
+
select /*+ QB_NAME(qb2) */ emp_id from (
558
+
select /*+ QB_NAME(qb3) */ emp_id from (
559
+
select /*+ QB_NAME(qb4) */ emp_id from (
560
+
select emp_id from employees) dt) du) dv) dw;
561
+
id select_type table type possible_keys key key_len ref rows filtered Extra
562
+
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 100.00
563
+
3 DERIVED <derived5> ALL NULL NULL NULL NULL 2 100.00
564
+
5 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
565
+
Warnings:
566
+
Note 1003 /* select#1 */ select /*+ NO_MERGE(@`qb4`) NO_MERGE(@`qb2`) */ `dv`.`emp_id` AS `emp_id` from (/* select#3 */ select /*+ QB_NAME(`qb3`) */ `dt`.`emp_id` AS `emp_id` from (/* select#5 */ select `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dt`) `dv`
567
+
# Test the MERGE hint variant
568
+
set session optimizer_switch='derived_merge=off';
569
+
EXPLAIN EXTENDED SELECT /*+ MERGE() */ e.emp_name, s.salary FROM (
570
+
select * from employees) e JOIN (select * from salaries) s ON e.emp_id = s.emp_id;
571
+
id select_type table type possible_keys key key_len ref rows filtered Extra
572
+
1 SIMPLE salaries ALL emp_id NULL NULL NULL 2 100.00 Using where
Note 1003 select /*+ MERGE(@`select#1`) */ `test`.`employees`.`emp_name` AS `emp_name`,`test`.`salaries`.`salary` AS `salary` from `test`.`employees` join `test`.`salaries` where `test`.`employees`.`emp_id` = `test`.`salaries`.`emp_id`
Note 1003 select /*+ QB_NAME(`foo`) MERGE(@`foo`) */ `test`.`employees`.`emp_name` AS `emp_name`,`test`.`salaries`.`salary` AS `salary` from `test`.`employees` join `test`.`salaries` where `test`.`employees`.`emp_id` = `test`.`salaries`.`emp_id`
583
+
EXPLAIN EXTENDED
584
+
select /*+ MERGE() */ emp_id from (
585
+
select /*+ MERGE() */ emp_id from (
586
+
select /*+ MERGE() */ emp_id from (
587
+
select /*+ MERGE() */ emp_id from (
588
+
select emp_id from employees) dt) du) dv) dw;
589
+
id select_type table type possible_keys key key_len ref rows filtered Extra
590
+
1 SIMPLE employees index NULL PRIMARY 4 NULL 2 100.00 Using index
591
+
Warnings:
592
+
Note 1003 select /*+ MERGE(@`select#4`) MERGE(@`select#3`) MERGE(@`select#2`) MERGE(@`select#1`) */ `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`
593
+
EXPLAIN EXTENDED
594
+
select /*+ MERGE(@qb4) */ emp_id from (
595
+
select /*+ QB_NAME(qb2) */ emp_id from (
596
+
select /*+ QB_NAME(qb3) */ emp_id from (
597
+
select /*+ QB_NAME(qb4) */ emp_id from (
598
+
select emp_id from employees) dt) du) dv) dw;
599
+
id select_type table type possible_keys key key_len ref rows filtered Extra
600
+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
601
+
2 DERIVED <derived3> ALL NULL NULL NULL NULL 2 100.00
602
+
3 DERIVED <derived4> ALL NULL NULL NULL NULL 2 100.00
603
+
4 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
604
+
Warnings:
605
+
Note 1003 /* select#1 */ select /*+ MERGE(@`qb4`) */ `dw`.`emp_id` AS `emp_id` from (/* select#2 */ select /*+ QB_NAME(`qb2`) */ `dv`.`emp_id` AS `emp_id` from (/* select#3 */ select /*+ QB_NAME(`qb3`) */ `du`.`emp_id` AS `emp_id` from (/* select#4 */ select /*+ QB_NAME(`qb4`) */ `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `du`) `dv`) `dw`
606
+
EXPLAIN EXTENDED
607
+
select /*+ MERGE(@qb3) */ emp_id from (
608
+
select /*+ QB_NAME(qb2) */ emp_id from (
609
+
select /*+ QB_NAME(qb3) */ emp_id from (
610
+
select /*+ QB_NAME(qb4) */ emp_id from (
611
+
select emp_id from employees) dt) du) dv) dw;
612
+
id select_type table type possible_keys key key_len ref rows filtered Extra
613
+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
614
+
2 DERIVED <derived3> ALL NULL NULL NULL NULL 2 100.00
615
+
3 DERIVED <derived5> ALL NULL NULL NULL NULL 2 100.00
616
+
5 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
617
+
Warnings:
618
+
Note 1003 /* select#1 */ select /*+ MERGE(@`qb3`) */ `dw`.`emp_id` AS `emp_id` from (/* select#2 */ select /*+ QB_NAME(`qb2`) */ `dv`.`emp_id` AS `emp_id` from (/* select#3 */ select /*+ QB_NAME(`qb3`) */ `dt`.`emp_id` AS `emp_id` from (/* select#5 */ select `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dt`) `dv`) `dw`
619
+
EXPLAIN EXTENDED
620
+
select /*+ MERGE(@qb2) */ emp_id from (
621
+
select /*+ QB_NAME(qb2) */ emp_id from (
622
+
select /*+ QB_NAME(qb3) */ emp_id from (
623
+
select /*+ QB_NAME(qb4) */ emp_id from (
624
+
select emp_id from employees) dt) du) dv) dw;
625
+
id select_type table type possible_keys key key_len ref rows filtered Extra
626
+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
627
+
2 DERIVED <derived4> ALL NULL NULL NULL NULL 2 100.00
628
+
4 DERIVED <derived5> ALL NULL NULL NULL NULL 2 100.00
629
+
5 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
630
+
Warnings:
631
+
Note 1003 /* select#1 */ select /*+ MERGE(@`qb2`) */ `dw`.`emp_id` AS `emp_id` from (/* select#2 */ select /*+ QB_NAME(`qb2`) */ `du`.`emp_id` AS `emp_id` from (/* select#4 */ select /*+ QB_NAME(`qb4`) */ `dt`.`emp_id` AS `emp_id` from (/* select#5 */ select `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `dt`) `du`) `dw`
632
+
EXPLAIN EXTENDED
633
+
select /*+ MERGE(@qb2) MERGE(@qb4) */ emp_id from (
634
+
select /*+ QB_NAME(qb2) */ emp_id from (
635
+
select /*+ QB_NAME(qb3) */ emp_id from (
636
+
select /*+ QB_NAME(qb4) */ emp_id from (
637
+
select emp_id from employees) dt) du) dv) dw;
638
+
id select_type table type possible_keys key key_len ref rows filtered Extra
639
+
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
640
+
2 DERIVED <derived4> ALL NULL NULL NULL NULL 2 100.00
641
+
4 DERIVED employees index NULL PRIMARY 4 NULL 2 100.00 Using index
642
+
Warnings:
643
+
Note 1003 /* select#1 */ select /*+ MERGE(@`qb4`) MERGE(@`qb2`) */ `dw`.`emp_id` AS `emp_id` from (/* select#2 */ select /*+ QB_NAME(`qb2`) */ `du`.`emp_id` AS `emp_id` from (/* select#4 */ select /*+ QB_NAME(`qb4`) */ `test`.`employees`.`emp_id` AS `emp_id` from `test`.`employees`) `du`) `dw`
0 commit comments