Aggregation-in-order from query plan#43592
Merged
KochetovNicolai merged 10 commits intomasterfrom Dec 6, 2022
Merged
Conversation
Member
nickitat
reviewed
Dec 2, 2022
| bool group_by_use_nulls; | ||
|
|
||
| InputOrderInfoPtr group_by_info; | ||
| SortDescription sort_description_for_merging; |
Member
There was a problem hiding this comment.
we need a comment explaining the purpose of these two. maybe just a link to comment under optimisation
| if (enforce_aggregation_in_order) | ||
| reading->enforceAggregationInOrder(); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
would be good also to call updateInputStream on parent steps to propagate sorting
Member
Author
There was a problem hiding this comment.
Good idea.
Don't want to do it is this pr.
| /// We would like to have: | ||
| /// (a, b, c) - a sort description for reading from table (it's into input_order) | ||
| /// (a, c) - a sort description for merging (an input of AggregatingInOrderTransfrom is sorted by this GROUP BY keys) | ||
| /// (a, c, d) - a group by soer description (an input of FinishAggregatingInOrderTransform is sorted by all GROUP BY keys) |
Member
There was a problem hiding this comment.
Suggested change
| /// (a, c, d) - a group by soer description (an input of FinishAggregatingInOrderTransform is sorted by all GROUP BY keys) | |
| /// (a, c, d) - a group by sort description (an input of FinishAggregatingInOrderTransform is sorted by all GROUP BY keys) |
| MatchedTrees::Matches matches; | ||
| FixedColumns fixed_key_columns; | ||
|
|
||
| /// For every column in PK find any macth from GROUP BY key. |
Member
There was a problem hiding this comment.
Suggested change
| /// For every column in PK find any macth from GROUP BY key. | |
| /// For every column in PK find any match from GROUP BY key. |
Comment on lines
+722
to
+723
| //std::cerr << "------- matching " << static_cast<const void *>(node) << " " << node->result_name | ||
| // << " to " << static_cast<const void *>(match.node) << " " << (match.node ? match.node->result_name : "") << std::endl; |
Member
There was a problem hiding this comment.
Suggested change
| //std::cerr << "------- matching " << static_cast<const void *>(node) << " " << node->result_name | |
| // << " to " << static_cast<const void *>(match.node) << " " << (match.node ? match.node->result_name : "") << std::endl; |
| ErrorCodes::LOGICAL_ERROR, | ||
| "Cannot enforce aggregation in order for ReadFromRemote step up to stage {}", | ||
| QueryProcessingStage::toString(stage)); | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| context.setSetting("enable_memory_bound_merging_of_aggregation_results", true); |
Member
Author
There was a problem hiding this comment.
I would rather separate enforceAggregationInOrder and enforceSorting calls.
Member
Author
|
Checked query from perftest and don't see any difference: |
Member
Author
|
Merged cause only comments were changed since last checks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Implement
aggregation-in-orderoptimization on top of query plan. It is enabled by default (but works only together withoptimize_aggregation_in_order, which is disabled by default). Setquery_plan_aggregation_in_order = 0to use previous AST-based version.