-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add Exchange before GroupId to improve Partial Aggregation #24047
base: master
Are you sure you want to change the base?
Conversation
95fb49c
to
62aaab6
Compare
Thanks for the release note entry! Minor formatting nits, and include the PR number.
|
62aaab6
to
fa61dfd
Compare
fa61dfd
to
39222b3
Compare
86b145a
to
5868a2f
Compare
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.
high level first pass. Seems good for the most part. I will take another pass and look at the details of the rule tomorrow.
presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java
Show resolved
Hide resolved
...presto/sql/planner/iterative/rule/AddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Outdated
Show resolved
Hide resolved
...presto/sql/planner/iterative/rule/AddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Show resolved
Hide resolved
...ook/presto/sql/planner/TestLogicalAddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Show resolved
Hide resolved
5868a2f
to
437a09a
Compare
...presto/sql/planner/iterative/rule/AddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
return isEnabledAddExchangeBelowGroupId(session); |
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.
maybe this should have 3 possible values - ALWAYS, COST_BASED, and NEVER (similar to partial aggregation pushdown). that way someone can enable this if they don't have stats or if the stats estimates are no good.
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.
What would we re-partition on if ALWAYS is chosen (for the non-trivial case of more than one partition variable) ?
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.
good point. i guess we can leave as is for now, unless we want to has on all of them?
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.
I'm in favor of leaving this as-is until a use case arises for ALWAYS
...to/sql/planner/iterative/rule/TestAddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
public void testAddExchangesWithoutProjection() |
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.
what about a withProjection test. Also a test that it doesn't fire if it's disabled, only has one grouping set, has pass through keys.
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.
'only has one grouping set' , added with this test
withProjection, does not fire if disabled -> will add
only has one grouping set, has pass through keys -> I could not build a use-case where this occurs. My understanding of when this could occur is unclear. Can you help me out with an example ?
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.
sorry, i didn't mean one grouping set with pass through keys, i meant the case covered by https://github.com/prestodb/presto/pull/24047/files#diff-2e788a27c31ea3e4d5d404dba18eee33a3868d656bae3b0c0380269afb838f24, so multiple grouping sets that all share some common keys.
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.
@rschlussel I think I've covered all the test cases now. Please take a look
437a09a
to
979d204
Compare
The minor formatting nits should still apply, but new release note guidelines as of last week: PR #24354 automatically adds links to this PR to the release notes. Please remove the manual PR link in the following format from the release note entries for this PR.
I have updated the Release Notes Guidelines to remove the examples of manually adding the PR link. |
@steveburnett Thanks for the feedback! We're still working through some naming+defaults for the new session/feature flags. I will update the release notes + optimizer docs once we close on this |
0874d82
to
f95fab9
Compare
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. one minor thing
...presto/sql/planner/iterative/rule/AddExchangesBelowPartialAggregationOverGroupIdRuleSet.java
Outdated
Show resolved
Hide resolved
e196f21
to
74178b4
Compare
@@ -81,7 +81,9 @@ public GroupIdNode( | |||
{ | |||
super(sourceLocation, id, statsEquivalentPlanNode); | |||
this.source = requireNonNull(source); | |||
this.groupingSets = listOfListsCopy(requireNonNull(groupingSets, "groupingSets is null")); | |||
checkArgument(requireNonNull(groupingSets, "groupingSets is null").size() > 1, |
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.
I noticed that we only create a GroupId node iff the size of the grouping sets is >1. So adding this invariant here, made sense. No tests failed, so IMO this should be added cc: @rschlussel
Based on: trinodb/trino@dc1d66fb co-authored-by: Piotr Findeisen <piotr.findeisen@gmail.com> Based on : trinodb/trino@c573b34 co-authored-by: Lukasz Stec <lukasz.stec@starburstdata.com> Based on: trinodb/trino@29328d3 co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
74178b4
to
84cafec
Compare
See #23475 for more details
Previously closed PR - #11741
Description
Motivation and Context
See Javadoc of the new
AddExchangesBelowPartialAggregationOverGroupIdRuleSet
Impact
Better performance for TPCDS Q22, Q67
See plan diffs (TPCDS SF 1000, unpartitioned) - https://aaneja.github.io/mypages/PR_24047_AddExchangesBelowPartialAggregationOverGroupId_OffVsOn.html
Test Plan
TODO : Add a new planner test
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.