Skip to content

Commit 443a01a

Browse files
author
Steinar H. Gunderson
committed
Bug #31310238: SUPPORT SORTING MULTIPLE TABLES [patch 2/5, implementation] [noclose]
Make filesort support sorting a join of multiple tables, not just a single table. The biggest change is that the sort types that depend on row IDs need to support multiple ones instead of just one -- this means that we can do such sorts without having to materialize them (StreamingIterator already took care of most of the common cases, although with a fair bit of unneccessary copying). Filesort now takes in the estimate for number of rows (only used for excluding priority queue, if there are so few rows that we assume multiple buffers are not needed) from the estimates in the access path instead of asking the table, since there's not necessarily “one table” anymore. For some tests, this actually gives a more precise estimate, although it's likely to be fairly inconsequential in practice. Nothing in the executor currently sets up access paths with such multi-table sorts, since fields are always resolved to the temporary table (so it's not just a matter of changing), but the new optimizer will. Change-Id: I5304035b1fa36b622e7d58d5464d6b3ec0e50ba8
1 parent e4f60d2 commit 443a01a

24 files changed

+508
-361
lines changed

mysql-test/r/window_functions_explain.result

+6-6
Original file line numberDiff line numberDiff line change
@@ -16724,8 +16724,8 @@ join_optimization": {
1672416724
"memory_available": 262144,
1672516725
"key_size": "XXX",
1672616726
"row_size": "XXX",
16727-
"max_rows_per_buffer": 34,
16728-
"num_rows_estimate": 34,
16727+
"max_rows_per_buffer": "NNN",
16728+
"num_rows_estimate": 40,
1672916729
"num_rows_found": 24,
1673016730
"num_initial_chunks_spilled_to_disk": 0,
1673116731
"peak_memory_used": "NNN",
@@ -16754,8 +16754,8 @@ join_optimization": {
1675416754
"memory_available": 262144,
1675516755
"key_size": "XXX",
1675616756
"row_size": "XXX",
16757-
"max_rows_per_buffer": 34,
16758-
"num_rows_estimate": 34,
16757+
"max_rows_per_buffer": "NNN",
16758+
"num_rows_estimate": 18446744073709551615,
1675916759
"num_rows_found": 24,
1676016760
"num_initial_chunks_spilled_to_disk": 0,
1676116761
"peak_memory_used": "NNN",
@@ -16784,8 +16784,8 @@ join_optimization": {
1678416784
"memory_available": 262144,
1678516785
"key_size": "XXX",
1678616786
"row_size": "XXX",
16787-
"max_rows_per_buffer": 34,
16788-
"num_rows_estimate": 34,
16787+
"max_rows_per_buffer": "NNN",
16788+
"num_rows_estimate": 18446744073709551615,
1678916789
"num_rows_found": 24,
1679016790
"num_initial_chunks_spilled_to_disk": 0,
1679116791
"peak_memory_used": "NNN",

mysql-test/suite/opt_trace/include/general2.inc

+1
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ insert into t1 values(1),(2),(3);
679679
create database mysqltest2;
680680
create table mysqltest2.t2(a int);
681681
insert into mysqltest2.t2 values(1),(2);
682+
analyze table t1, mysqltest2.t2;
682683
--sorted_result
683684
select * from t1,mysqltest2.t2;
684685
SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;

mysql-test/suite/opt_trace/r/filesort_pack.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ select * from t1 order by c1 {
214214
"key_size": 1022,
215215
"row_size": 66561,
216216
"max_rows_per_buffer": 14,
217-
"num_rows_estimate": 215,
217+
"num_rows_estimate": 15,
218218
"num_rows_found": 0,
219219
"num_initial_chunks_spilled_to_disk": 0,
220220
"peak_memory_used": 0,
@@ -372,7 +372,7 @@ select * from t1 order by c1 {
372372
"key_size": 1022,
373373
"row_size": 66561,
374374
"max_rows_per_buffer": 14,
375-
"num_rows_estimate": 215,
375+
"num_rows_estimate": 15,
376376
"num_rows_found": 0,
377377
"num_initial_chunks_spilled_to_disk": 0,
378378
"peak_memory_used": 0,
@@ -530,7 +530,7 @@ select * from t1 order by c1 {
530530
"key_size": 1022,
531531
"row_size": 66561,
532532
"max_rows_per_buffer": 14,
533-
"num_rows_estimate": 215,
533+
"num_rows_estimate": 15,
534534
"num_rows_found": 0,
535535
"num_initial_chunks_spilled_to_disk": 0,
536536
"peak_memory_used": 0,

0 commit comments

Comments
 (0)