-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Improve performance of distinct aggregations #21907
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
Merged
Merged
Conversation
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
0d37869 to
abce86f
Compare
a8e0691 to
1dbce97
Compare
lukasz-stec
approved these changes
May 21, 2024
Member
lukasz-stec
left a comment
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 % comments
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
3c9b688 to
e1575ae
Compare
...no-main/src/main/java/io/trino/sql/planner/iterative/rule/DistinctAggregationController.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/DistinctAggregationToGroupBy.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/DistinctAggregationToGroupBy.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/OptimizerConfig.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/OptimizerConfig.java
Outdated
Show resolved
Hide resolved
9045fda to
12631c0
Compare
b1b21b8 to
e313705
Compare
6b76663 to
ece0e92
Compare
martint
reviewed
Jun 6, 2024
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
...in/src/main/java/io/trino/sql/planner/iterative/rule/DistinctAggregationStrategyChooser.java
Outdated
Show resolved
Hide resolved
Extract the logic to determine whether the direct distinct aggregation applicability, which can be reused in multiple optimiser rules.
sopel39
reviewed
Jun 7, 2024
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
sopel39
reviewed
Jun 7, 2024
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
1cfd72d to
806f79a
Compare
0de1457 to
04d7275
Compare
Move class before refactoring to preserve history
Adds support for multiple distinct aggregations in OptimizeMixedDistinctAggregations`.
Replace optimizer.optimize-mixed-distinct-aggregations with a new optimizer.distinct-aggregations-strategy `pre_aggregate`. Also rename corresponding config property optimizer.mark-distinct-strategy to optimizer.distinct-aggregations-strategy and values to NONE -> SINGLE_STEP and ALWAYS -> MARK_DISTINCT
Use estimated aggregation source NDV and the number of grouping keys to decide if pre-aggregate strategy should be used for a given aggregation
This was referenced Jul 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cla-signed
delta-lake
Delta Lake connector
docs
hive
Hive connector
hudi
Hudi connector
iceberg
Iceberg connector
performance
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.
Description
Improve performance of distinct aggregations by defining additional strategies based on source properties (for example, NDV).
The strategy to use for multiple distinct aggregations.
SINGLE_STEPComputes distinct aggregations in single-step without any pre-aggregations.This strategy will perform poorly if the number of distinct grouping keys is small.
MARK_DISTINCTusesMarkDistinctfor multiple distinct aggregationsor for mix of distinct and non-distinct aggregations.
PRE_AGGREGATEComputes distinct aggregations using a combination of aggregationand pre-aggregation steps.
AUTOMATICchooses the strategy automatically.Single-step strategy is preferred. However, for cases with limited concurrency due to
a small number of distinct grouping keys, it will choose an alternative strategy
based on input data statistics.
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: