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

perf: Eliminate duplicate aggregations #132

Merged
merged 2 commits into from
Feb 7, 2024
Merged

perf: Eliminate duplicate aggregations #132

merged 2 commits into from
Feb 7, 2024

Conversation

KKould
Copy link
Member

@KKould KKould commented Feb 7, 2024

What problem does this PR solve?

When Distinct and GroupBy exist at the same time, and groupby_exprs are consistent, Distinct can be eliminated.

Add Rule

  • NormalizationRuleImpl::CollapseGroupByAgg
28156=> explain select distinct a, b from t1 group by a, b; 
                       PLAN                                                                                                                                                                                                        
---------------------------------------------------
 Projection [a, b] [Project]                      +
   Aggregate [] -> Group By [a, b] [HashAggregate]+
     Scan t1 -> [a, b] [SeqScan]
(1 row)

28156=> explain select distinct a, b, sum(k) from t1 group by a, b; 
                           PLAN                                                                                                                                                                                                    
-----------------------------------------------------------
 Projection [a, b, Sum(k)] [Project]                      +
   Aggregate [] -> Group By [a, b, Sum(k)] [HashAggregate]+
     Aggregate [Sum(k)] -> Group By [a, b] [HashAggregate]+
       Scan t1 -> [a, b, k] [SeqScan]
(1 row)

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

@KKould KKould added the enhancement New feature or request label Feb 7, 2024
@KKould KKould self-assigned this Feb 7, 2024
@KKould KKould mentioned this pull request Feb 7, 2024
51 tasks
@KKould KKould merged commit bb9ccef into KipData:main Feb 7, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant