-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Gather partial TopN results #21761
Gather partial TopN results #21761
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
f2fbc4f
to
98b4c2a
Compare
import static io.trino.sql.planner.plan.TopNNode.Step.PARTIAL; | ||
|
||
/** | ||
* Adds local round-robin and gathering exchange on top of partial TopN to limit the task output size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How big of an issue is this? For a leaf task, the output is currently N * number_of_splits. With this change, it's N. But if N is small, this may not be such big of a deal in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here are some numbers
trino:iceberg_small_files_tpch_sf1000_orc_part> explain analyze verbose select * from lineitem order by orderkey limit 10000;
Before
Output: 2947463228 rows (419.40GB)
...
CPU Time: 18061.8s total, 332K rows/s, 9.04MB/s, 45% active
Per Node: 9.9 parallelism, 3.29M rows/s, 89.6MB/s
Parallelism: 69.4
Peak Memory: 1.07GB
4:20 [6B rows, 159GB] [23.1M rows/s, 627MB/s]
After
Output: 60000 rows (8.75MB)
...
CPU Time: 17139.7s total, 350K rows/s, 9.53MB/s, 34% active
Per Node: 17.7 parallelism, 6.2M rows/s, 169MB/s
Parallelism: 123.9
Peak Memory: 1.62GB
2:18 [6B rows, 159GB] [43.4M rows/s, 1.15GB/s]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice win 👍
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
Gathering TopN avoids unnecessary network overhead, especially when both the number of splits and the TopN limit are big. Co-authored-by: Kamil Endruszkiewicz <kamil.endruszkiewicz@starburstdata.com>
Description
Gathering TopN avoids unnecessary network overhead, especially when both the number of splits and the TopN limit are big.
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: