Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit aef96ff

Browse files
lthHerman Lee
authored andcommitted
Only generate BKA plans that maintains sort order
Summary: If the storage engine supports sorted MRR, and this is not part of an outer join, then BKA will actually always produce ordered results. Outer joins are unordered because the BKA algorithm outputs matching rows first, followed by non-matching rows. It is probably possible to extend `BKAIterator::Read` to always produced sorted rows if sorted MRR is supported, and get rid of the outer join check. The current check also includes antijoins, even though antijoins also produce sorted output. Because the decision to use BKA is not cost based, and it is always chosen if available, it will sometimes regress plans when NLJ can skip filesort while BKA cannot skip filesort. To fix this, produce BKA only if it produces ordered results, or if there's no order by clause. If the order by clause does not match the order of the outer table, then technically BKA is still usable, since filesort is needed regardless of BKA/NLJ. This case is not handled here, and NLJ will always be chosen. Reviewed By: luqun Differential Revision: D35678857
1 parent 1cf1bcd commit aef96ff

13 files changed

Lines changed: 294 additions & 52 deletions

‎mysql-test/include/diff_query.inc‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--disable_query_log
2+
3+
--output $MYSQL_TMP_DIR/A
4+
--eval $query
5+
6+
--eval $setup
7+
--output $MYSQL_TMP_DIR/B
8+
--eval $query
9+
--eval $restore
10+
11+
--enable_query_log
12+
13+
--diff_files $MYSQL_TMP_DIR/A $MYSQL_TMP_DIR/B
14+
15+
--remove_file $MYSQL_TMP_DIR/A
16+
--remove_file $MYSQL_TMP_DIR/B

‎mysql-test/r/join_cache_bka.result‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,8 @@ explain
15261526
select t1.a, count(t2.p) as count
15271527
from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
15281528
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1529-
1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index; Using temporary
1530-
1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where; Using join buffer (Batched Key Access)
1529+
1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index
1530+
1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where
15311531
Warnings:
15321532
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a`
15331533
select t1.a, count(t2.p) as count
@@ -1888,8 +1888,8 @@ explain
18881888
select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1
18891889
where t1.d=3 group by t1.id1;
18901890
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1891-
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary
1892-
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 Using join buffer (Batched Key Access)
1891+
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index
1892+
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 NULL
18931893
Warnings:
18941894
Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1`
18951895
select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1
@@ -2475,7 +2475,7 @@ ORDER BY t1.col_int_key, t1.col_datetime
24752475
LIMIT 2;
24762476
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
24772477
1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort
2478-
1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where; Using join buffer (Batched Key Access)
2478+
1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where
24792479
Warnings:
24802480
Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2
24812481
SELECT t1.col_int_key, t1.col_datetime
@@ -2778,8 +2778,8 @@ ON t1.col_varchar_key = t2.col_varchar_key
27782778
GROUP BY field2
27792779
ORDER BY field1;
27802780
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2781-
1 SIMPLE t1 NULL index col_int_key,col_varchar_key col_varchar_key 10 NULL 3 100.00 Using index; Using temporary; Using filesort
2782-
1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 Using join buffer (Batched Key Access)
2781+
1 SIMPLE t1 NULL index col_int_key,col_varchar_key col_int_key 4 NULL 3 100.00 Using temporary; Using filesort
2782+
1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 NULL
27832783
Warnings:
27842784
Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1`
27852785
SELECT MIN(t2.col_datetime_key) AS field1,
@@ -2847,7 +2847,7 @@ GROUP BY field1 , field4
28472847
ORDER BY t1.col_datetime_key ;
28482848
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
28492849
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
2850-
1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 Using join buffer (Batched Key Access)
2850+
1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 NULL
28512851
Warnings:
28522852
Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key`
28532853
SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4

‎mysql-test/r/join_cache_bka_nobnl.result‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,8 @@ explain
15261526
select t1.a, count(t2.p) as count
15271527
from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
15281528
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1529-
1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index; Using temporary
1530-
1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where; Using join buffer (Batched Key Access)
1529+
1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index
1530+
1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where
15311531
Warnings:
15321532
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a`
15331533
select t1.a, count(t2.p) as count
@@ -1888,8 +1888,8 @@ explain
18881888
select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1
18891889
where t1.d=3 group by t1.id1;
18901890
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1891-
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary
1892-
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 Using join buffer (Batched Key Access)
1891+
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index
1892+
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 NULL
18931893
Warnings:
18941894
Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1`
18951895
select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1
@@ -1902,8 +1902,8 @@ explain
19021902
select t1.id1 from t1 join t2 on t1.id1=t2.id1
19031903
where t1.d=3 and t2.id2 > 200 order by t1.id1;
19041904
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1905-
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary; Using filesort
1906-
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 33.33 Using where; Using join buffer (Batched Key Access)
1905+
1 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index
1906+
1 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 33.33 Using where
19071907
Warnings:
19081908
Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1`
19091909
select t1.id1 from t1 join t2 on t1.id1=t2.id1
@@ -2475,7 +2475,7 @@ ORDER BY t1.col_int_key, t1.col_datetime
24752475
LIMIT 2;
24762476
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
24772477
1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort
2478-
1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where; Using join buffer (Batched Key Access)
2478+
1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where
24792479
Warnings:
24802480
Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2
24812481
SELECT t1.col_int_key, t1.col_datetime
@@ -2778,8 +2778,8 @@ ON t1.col_varchar_key = t2.col_varchar_key
27782778
GROUP BY field2
27792779
ORDER BY field1;
27802780
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2781-
1 SIMPLE t1 NULL index col_int_key,col_varchar_key col_varchar_key 10 NULL 3 100.00 Using index; Using temporary; Using filesort
2782-
1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 Using join buffer (Batched Key Access)
2781+
1 SIMPLE t1 NULL index col_int_key,col_varchar_key col_int_key 4 NULL 3 100.00 Using temporary; Using filesort
2782+
1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 NULL
27832783
Warnings:
27842784
Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1`
27852785
SELECT MIN(t2.col_datetime_key) AS field1,
@@ -2847,7 +2847,7 @@ GROUP BY field1 , field4
28472847
ORDER BY t1.col_datetime_key ;
28482848
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
28492849
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
2850-
1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 Using join buffer (Batched Key Access)
2850+
1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 NULL
28512851
Warnings:
28522852
Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key`
28532853
SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4

‎mysql-test/r/select_all_bka.result‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,19 +643,19 @@ Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3`
643643
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
644644
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
645645
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
646-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
646+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
647647
Warnings:
648648
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period`
649649
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
650650
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
651-
1 SIMPLE t3 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
652-
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 Using join buffer (Batched Key Access)
651+
1 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL
652+
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 NULL
653653
Warnings:
654654
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10
655655
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
656656
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
657-
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
658-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
657+
1 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL
658+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
659659
Warnings:
660660
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10
661661
select period from t1;

‎mysql-test/r/select_all_bka_nobnl.result‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,19 +643,19 @@ Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3`
643643
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
644644
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
645645
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
646-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
646+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
647647
Warnings:
648648
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period`
649649
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
650650
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
651-
1 SIMPLE t3 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
652-
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 Using join buffer (Batched Key Access)
651+
1 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL
652+
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 NULL
653653
Warnings:
654654
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10
655655
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
656656
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
657-
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
658-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
657+
1 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL
658+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
659659
Warnings:
660660
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10
661661
select period from t1;

‎mysql-test/r/select_icp_mrr_bka.result‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,19 +643,19 @@ Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3`
643643
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
644644
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
645645
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
646-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
646+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
647647
Warnings:
648648
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period`
649649
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
650650
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
651-
1 SIMPLE t3 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
652-
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 Using join buffer (Batched Key Access)
651+
1 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL
652+
1 SIMPLE t1 NULL ref period period 4 test.t3.period 4181 100.00 NULL
653653
Warnings:
654654
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10
655655
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
656656
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
657-
1 SIMPLE t1 NULL ALL period NULL NULL NULL 41810 100.00 Using temporary; Using filesort
658-
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 Using join buffer (Batched Key Access)
657+
1 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL
658+
1 SIMPLE t3 NULL ref period period 4 test.t1.period 4181 100.00 NULL
659659
Warnings:
660660
Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10
661661
select period from t1;

0 commit comments

Comments
 (0)