devanshu0987 opened a new pull request, #20180:
URL: https://github.com/apache/datafusion/pull/20180

   ## Which issue does this PR close?
   
   - Closes #.
   
   ## Rationale for this change
   
   - ClickBench Query 29 executes 90 separate SUM operations:
     - `SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 
2), ..., SUM(ResolutionWidth + 89)`
   - 
https://www.redpanda.com/blog/oxla-our-road-to-improving-oxla-results-on-clickbench#what-we-had-to-optimize
     - This blog post from Redpand mentioned an optimization they did to 
optimize this query.
   - **Transform aggregations `SUM(A + k)` into `SUM(A) + k * COUNT(*)`** 
   - This will transform 90 SUM aggregations into 1 SUM and 1 COUNT aggregation 
and the results will be reused for all projections.
     - It is added before `CommonSubexprEliminate` to allow re use of the 
common SUM and COUNT expression.
   
   
   ## What changes are included in this PR?
   
   - New optimizer rule `RewriteAggregateWithConstant`
   
   ## Are these changes tested?
   
   - Unit Tests
   - SLT Tests
   - Explain over Query 29 shows the reuse
     - I would like the core-contributors to run the benchmark to prove the 
impact.
   
   ## Are there any user-facing changes?
   
   No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to