You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Tech Request]: Optimize aggregate functions with distinct keyword #9049
kind/tech-requestNew feature or requestpriority/p0Critical feature that should be implemented in this versionseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.source/devissues from devs
Is there an existing issue for the same feature request?
I have checked the existing issues.
Is your feature request related to a problem?
Current implementation of distinct aggregate is using hash-table in hash-table.It's inefficient, in both memory and performance.
On my desktop machine with 32GB memory, TPCH SF=100 q16 causes OOM due to this bad implementation.
Describe the feature you'd like
In plan, we should rewrite AGG nodes which have distinct aggregate function with multiple AGG nodes.
max/min/any_value (just omit DISTINCT keyword)
count/sum
avg
distinct aggregate coexists with normal aggregates
multiple distinct aggregates
Describe implementation you've considered
No response
Documentation, Adoption, Use Case, Migration Strategy
changed the title [-][Feature Request]: Optimize aggregate functions with distinct keyword[/-][+][Tech Request]: Optimize aggregate functions with distinct keyword[/+]on Nov 8, 2023
Superseded by #30768, assigned to @matrix-meow, for the remaining mixed/multiple DISTINCT aggregation optimization.
Inspected main c232b6d2a1b5a94ac624c4954586569841c1e153: standalone AVG(DISTINCT) is now rewritten (#28644), alongside the existing single COUNT/SUM rewrite; mixed COUNT DISTINCT parallelism (#27693) and bounded exact COUNT spill (#28003) have also landed. The old checklist therefore understates completed work.
The general rewrite still requires one aggregate expression. Mixed and multiple DISTINCT aggregate optimization remains explicit in #30768; adaptive exact-key partition parallelism continues under #27720, and window DISTINCT is separate (#29934).
Closing this historical umbrella as superseded, not as proof that all original requirements are implemented. The original TPCH SF=100 Q16 / 32GB OOM scenario was not rerun and is not claimed resolved by this status migration.
kind/tech-requestNew feature or requestpriority/p0Critical feature that should be implemented in this versionseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.source/devissues from devs
Activity
[-][Feature Request]: [/-][+][Feature Request]: Optimze aggregate functions with distinct keyword[/+][-][Feature Request]: Optimze aggregate functions with distinct keyword[/-][+][Feature Request]: Optimize aggregate functions with distinct keyword[/+][-][Feature Request]: Optimize aggregate functions with distinct keyword[/-][+][Tech Request]: Optimize aggregate functions with distinct keyword[/+]perf(plan): rewrite standalone AVG(DISTINCT) through grouped deduplic…
perf(plan): rewrite standalone AVG(DISTINCT) through grouped deduplic…
perf(plan): rewrite standalone AVG(DISTINCT) through grouped deduplic…
perf(plan): rewrite standalone AVG(DISTINCT) through grouped deduplic…
XuPeng-SH commentedon Oct 22, 2026
Superseded by #30768, assigned to @matrix-meow, for the remaining mixed/multiple DISTINCT aggregation optimization.
Inspected main
c232b6d2a1b5a94ac624c4954586569841c1e153: standalone AVG(DISTINCT) is now rewritten (#28644), alongside the existing single COUNT/SUM rewrite; mixed COUNT DISTINCT parallelism (#27693) and bounded exact COUNT spill (#28003) have also landed. The old checklist therefore understates completed work.The general rewrite still requires one aggregate expression. Mixed and multiple DISTINCT aggregate optimization remains explicit in #30768; adaptive exact-key partition parallelism continues under #27720, and window DISTINCT is separate (#29934).
Closing this historical umbrella as superseded, not as proof that all original requirements are implemented. The original TPCH SF=100 Q16 / 32GB OOM scenario was not rerun and is not claimed resolved by this status migration.