Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window sort support limit offset #4959

Closed
evenyag opened this issue Nov 7, 2024 · 6 comments · Fixed by #5018
Closed

Window sort support limit offset #4959

evenyag opened this issue Nov 7, 2024 · 6 comments · Fixed by #5018
Assignees
Labels
C-enhancement Category Enhancements

Comments

@evenyag
Copy link
Contributor

evenyag commented Nov 7, 2024

What type of enhancement is this?

Performance

What does the enhancement do?

Now window sort only supports limit without offset.

mysql> explain analyze select ts from cpu order by ts desc limit 1, 100;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| stage | node | plan                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     0 |    0 |  MergeScanExec: peers=[4398046511104(1024, 0), ] metrics=[output_rows: 100, greptime_exec_read_cost: 0, ready_time: 1367518, first_consume_time: 2405064866, finish_time: 2405182055, ]
                                                                                                                                                                                                                                                                                   |
|     1 |    0 |  GlobalLimitExec: skip=1, fetch=100 metrics=[output_rows: 100, elapsed_compute: 1112, ]
  SortExec: TopK(fetch=101), expr=[ts@0 DESC], preserve_partitioning=[false] metrics=[output_rows: 101, elapsed_compute: 1542010568, row_replacements: 26402, ]
    SeqScan: region=4398046511104(1024, 0), partition_count=1 (0 memtable ranges, 6 file 1016 ranges) metrics=[output_rows: 103680000, mem_used: 1058324480, elapsed_poll: 626485335, elapsed_await: 809918628, ]
 |
|  NULL | NULL | Total rows: 100                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (2.43 sec)

Support offset can reduce fetching all rows.

Implementation challenges

No response

@evenyag evenyag added the C-enhancement Category Enhancements label Nov 7, 2024
@LYZJU2019
Copy link
Contributor

Can I give it a try?

@evenyag
Copy link
Contributor Author

evenyag commented Nov 11, 2024

@waynexia Are you working on this?

@waynexia
Copy link
Member

Sorry for the delay, I have written some code on this ticket but haven't noticed the update on this issue 😢 Are you willing to give a review when it's ready @LYZJU2019 ?

@waynexia waynexia self-assigned this Nov 14, 2024
@LYZJU2019
Copy link
Contributor

Sure! Will try

@waynexia
Copy link
Member

FYI: #5018

@evenyag
Copy link
Contributor Author

evenyag commented Nov 19, 2024

Offset is already supported in the latest main, I guess #4960 already fixed this. 🥵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants