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
For ordered aggregation, we can likely simplify the implementation in a similar way to #23309.
The ordered aggregation case can be split into two variants:
Fully ordered input: the input is ordered by (a, b), and the query groups by (a, b)
Partially ordered input: the input is ordered by a, and the query groups by (a, b)
For the partially ordered variant, we should still use regular hash aggregation, with the early-emit optimization. For the fully ordered variant, there may be a deeper optimization that avoids the hash table entirely.
This refactor is probably easier after we first add the fast path for the fully ordered case. 🤔
Current main is about +1785 ms/round slower. The main stable contributors are q39 and q78.
Per-query comparison:
Query
Before
Current main
Delta
q39
~1274 ms
~1962 ms
+688 ms
q78
~655 ms
~1121 ms
+466 ms
Both q39 and q78 contain AggregateExec ... ordering_mode=PartiallySorted(...).
The likely cause is that after #23181, these partially sorted aggregate cases are routed through the new ordered partial/final aggregate streams. For these TPC-DS queries, that path appears slower than the previous regular hash aggregation path with early emit. Debug metrics also suggest the extra time is concentrated in the aggregate emitting path.
This seems consistent with the point in this issue that partially ordered input should likely still use regular hash aggregation with the early-emit optimization, while fully ordered input may need a separate optimized path.
Activity
hhhizzz commentedon Jul 6, 2026
I found a TPC-DS SF10 performance regression on current
mainthat appears related to the partially ordered aggregation path.Environment:
6a0e76ed692afaafd616e0d98d51bef63c1ff02dResult summary:
4d898e93f07b335b771231090.78 ms6a0e76ed69d8d980bdcf32876.21 msCurrent
mainis about+1785 ms/roundslower. The main stable contributors are q39 and q78.Per-query comparison:
1274 ms1962 ms688 ms655 ms1121 ms466 msBoth q39 and q78 contain
AggregateExec ... ordering_mode=PartiallySorted(...).The likely cause is that after #23181, these partially sorted aggregate cases are routed through the new ordered partial/final aggregate streams. For these TPC-DS queries, that path appears slower than the previous regular hash aggregation path with early emit. Debug metrics also suggest the extra time is concentrated in the aggregate emitting path.
This seems consistent with the point in this issue that partially ordered input should likely still use regular hash aggregation with the early-emit optimization, while fully ordered input may need a separate optimized path.
2010YOUY01 commentedon Jul 7, 2026
I suspect the root cause is something similar to #23251
For now we might want to do some patches without significant structural changes, eventually they should be reworked after #7065