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
This patch corrects the patch for the bug 10006. The latter incorrectly
calculates the attribute TABLE_LIST::dep_tables for inner tables
of outer joins that are to be converted into inner joins.
As a result after the patch some valid join orders were not evaluated
and the optimizer could choose an execution plan that was far from
being optimal.
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416 AND
2608
+
t2.REVTYPE=2;
2609
+
id select_type table type possible_keys key key_len ref rows filtered Extra
2610
+
1 SIMPLE t2 ALL NULL NULL NULL NULL 42 100.00 Using where
2611
+
1 SIMPLE t3 ref PRIMARY PRIMARY 4 test.t2.profile_id 1 100.00 Using where
2612
+
1 SIMPLE t4 ref PRIMARY PRIMARY 4 test.t3.person_id 1 100.00 Using index
2613
+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.REV 1 100.00 Using where
2614
+
Warnings:
2615
+
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`timestamp` AS `timestamp`,`test`.`t1`.`modifiedBy` AS `modifiedBy`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`REV` AS `REV`,`test`.`t2`.`REVTYPE` AS `REVTYPE`,`test`.`t2`.`profile_id` AS `profile_id`,`test`.`t3`.`id` AS `id`,`test`.`t3`.`REV` AS `REV`,`test`.`t3`.`person_id` AS `person_id`,`test`.`t4`.`id` AS `id`,`test`.`t4`.`REV` AS `REV` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t2`.`REVTYPE` = 2) and (`test`.`t4`.`id` = `test`.`t3`.`person_id`) and (`test`.`t3`.`id` = `test`.`t2`.`profile_id`) and (`test`.`t1`.`id` = `test`.`t2`.`REV`) and (`test`.`t1`.`timestamp` < 1294664900039) and (`test`.`t1`.`timestamp` > 1294644616416))
2616
+
SELECT *
2617
+
FROM t1 INNER JOIN t2 ON t2.REV=t1.id
2618
+
INNER JOIN t3 ON t3.id=t2.profile_id
2619
+
INNER JOIN t4 ON t4.id=t3.person_id
2620
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416 AND
2621
+
t2.REVTYPE=2;
2622
+
id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
# This should have join order of t2,t3,t4,t1 with the same plan as above
2627
+
# because all RIGHT JOIN operations are converted into INNER JOIN
2628
+
EXPLAIN EXTENDED SELECT *
2629
+
FROM t1 RIGHT JOIN t2 ON t2.REV=t1.id
2630
+
RIGHT JOIN t3 ON t3.id=t2.profile_id
2631
+
RIGHT JOIN t4 ON t4.id=t3.person_id
2632
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416
2633
+
AND t2.REVTYPE=2;
2634
+
id select_type table type possible_keys key key_len ref rows filtered Extra
2635
+
1 SIMPLE t2 ALL NULL NULL NULL NULL 42 100.00 Using where
2636
+
1 SIMPLE t3 ref PRIMARY PRIMARY 4 test.t2.profile_id 1 100.00 Using where
2637
+
1 SIMPLE t4 ref PRIMARY PRIMARY 4 test.t3.person_id 1 100.00 Using index
2638
+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.REV 1 100.00 Using where
2639
+
Warnings:
2640
+
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`timestamp` AS `timestamp`,`test`.`t1`.`modifiedBy` AS `modifiedBy`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`REV` AS `REV`,`test`.`t2`.`REVTYPE` AS `REVTYPE`,`test`.`t2`.`profile_id` AS `profile_id`,`test`.`t3`.`id` AS `id`,`test`.`t3`.`REV` AS `REV`,`test`.`t3`.`person_id` AS `person_id`,`test`.`t4`.`id` AS `id`,`test`.`t4`.`REV` AS `REV` from `test`.`t4` join `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`REVTYPE` = 2) and (`test`.`t1`.`id` = `test`.`t2`.`REV`) and (`test`.`t3`.`id` = `test`.`t2`.`profile_id`) and (`test`.`t4`.`id` = `test`.`t3`.`person_id`) and (`test`.`t1`.`timestamp` < 1294664900039) and (`test`.`t1`.`timestamp` > 1294644616416))
2641
+
SELECT *
2642
+
FROM t1 RIGHT JOIN t2 ON t2.REV=t1.id
2643
+
RIGHT JOIN t3 ON t3.id=t2.profile_id
2644
+
RIGHT JOIN t4 ON t4.id=t3.person_id
2645
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416
2646
+
AND t2.REVTYPE=2;
2647
+
id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416 AND
2619
+
t2.REVTYPE=2;
2620
+
id select_type table type possible_keys key key_len ref rows filtered Extra
2621
+
1 SIMPLE t2 ALL NULL NULL NULL NULL 42 100.00 Using where
2622
+
1 SIMPLE t3 ref PRIMARY PRIMARY 4 test.t2.profile_id 1 100.00 Using where
2623
+
1 SIMPLE t4 ref PRIMARY PRIMARY 4 test.t3.person_id 1 100.00 Using index
2624
+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.REV 1 100.00 Using where
2625
+
Warnings:
2626
+
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`timestamp` AS `timestamp`,`test`.`t1`.`modifiedBy` AS `modifiedBy`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`REV` AS `REV`,`test`.`t2`.`REVTYPE` AS `REVTYPE`,`test`.`t2`.`profile_id` AS `profile_id`,`test`.`t3`.`id` AS `id`,`test`.`t3`.`REV` AS `REV`,`test`.`t3`.`person_id` AS `person_id`,`test`.`t4`.`id` AS `id`,`test`.`t4`.`REV` AS `REV` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t2`.`REVTYPE` = 2) and (`test`.`t4`.`id` = `test`.`t3`.`person_id`) and (`test`.`t3`.`id` = `test`.`t2`.`profile_id`) and (`test`.`t1`.`id` = `test`.`t2`.`REV`) and (`test`.`t1`.`timestamp` < 1294664900039) and (`test`.`t1`.`timestamp` > 1294644616416))
2627
+
SELECT *
2628
+
FROM t1 INNER JOIN t2 ON t2.REV=t1.id
2629
+
INNER JOIN t3 ON t3.id=t2.profile_id
2630
+
INNER JOIN t4 ON t4.id=t3.person_id
2631
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416 AND
2632
+
t2.REVTYPE=2;
2633
+
id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
# This should have join order of t2,t3,t4,t1 with the same plan as above
2638
+
# because all RIGHT JOIN operations are converted into INNER JOIN
2639
+
EXPLAIN EXTENDED SELECT *
2640
+
FROM t1 RIGHT JOIN t2 ON t2.REV=t1.id
2641
+
RIGHT JOIN t3 ON t3.id=t2.profile_id
2642
+
RIGHT JOIN t4 ON t4.id=t3.person_id
2643
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416
2644
+
AND t2.REVTYPE=2;
2645
+
id select_type table type possible_keys key key_len ref rows filtered Extra
2646
+
1 SIMPLE t2 ALL NULL NULL NULL NULL 42 100.00 Using where
2647
+
1 SIMPLE t3 ref PRIMARY PRIMARY 4 test.t2.profile_id 1 100.00 Using where
2648
+
1 SIMPLE t4 ref PRIMARY PRIMARY 4 test.t3.person_id 1 100.00 Using index
2649
+
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.REV 1 100.00 Using where
2650
+
Warnings:
2651
+
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`timestamp` AS `timestamp`,`test`.`t1`.`modifiedBy` AS `modifiedBy`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`REV` AS `REV`,`test`.`t2`.`REVTYPE` AS `REVTYPE`,`test`.`t2`.`profile_id` AS `profile_id`,`test`.`t3`.`id` AS `id`,`test`.`t3`.`REV` AS `REV`,`test`.`t3`.`person_id` AS `person_id`,`test`.`t4`.`id` AS `id`,`test`.`t4`.`REV` AS `REV` from `test`.`t4` join `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`REVTYPE` = 2) and (`test`.`t1`.`id` = `test`.`t2`.`REV`) and (`test`.`t3`.`id` = `test`.`t2`.`profile_id`) and (`test`.`t4`.`id` = `test`.`t3`.`person_id`) and (`test`.`t1`.`timestamp` < 1294664900039) and (`test`.`t1`.`timestamp` > 1294644616416))
2652
+
SELECT *
2653
+
FROM t1 RIGHT JOIN t2 ON t2.REV=t1.id
2654
+
RIGHT JOIN t3 ON t3.id=t2.profile_id
2655
+
RIGHT JOIN t4 ON t4.id=t3.person_id
2656
+
WHERE t1.timestamp < 1294664900039 AND t1.timestamp > 1294644616416
2657
+
AND t2.REVTYPE=2;
2658
+
id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
0 commit comments