Add per-aggregate argument evaluation metrics for grouped hash aggregation - #24024
Open
kosiew wants to merge 6 commits into
Open
Add per-aggregate argument evaluation metrics for grouped hash aggregation#24024kosiew wants to merge 6 commits into
kosiew wants to merge 6 commits into
Conversation
…metric, wire grouped hash aggregation, and add regression test for SUM labels
- Add AggregateArgumentMetrics
- Add agg_expr_{idx}_arguments_time{aggregate=...}
- Wire grouped hash:
- legacy GroupedHashAggregateStream
- migrated hash table
- ordered migrated table
- skip-partial conversion path
- Add regression test for SUM(a) vs SUM(b) labels
…ric_label, add AggregateArgumentMetrics::time helper, simplify timer guard boilerplate, narrow test metric filter, and add sum_aggregate and count_aggregate test helpers
…s for ordered tables - Introduce a private `OrderedAggregateTableMetrics` class that bundles `GroupByMetrics` and `AggregateArgumentMetrics`. - Update ordered table constructors to accept the combined metrics bundle instead of separate `group_by_metrics` and `partition` parameters. - Modify spill replay logic to reuse the full metrics bundle from the table, eliminating the need for recomputation.
…g_expr_0_arguments_time are measured and non‑zero; adjust skip‑partial test to use two batches - Wrap aggregate argument evaluation in `transform_to_states` with existing `aggregate_arguments_time` - Update the skip‑partial test to use two batches to exercise the skip path - Add assertions that both `aggregate_arguments_time` and `agg_expr_0_arguments_time` exist and are non‑zero
…d debug_assert! bounds check in AggregateArgumentMetrics::time
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24024 +/- ##
========================================
Coverage 80.86% 80.86%
========================================
Files 1099 1099
Lines 374720 374904 +184
Branches 374720 374904 +184
========================================
+ Hits 303015 303183 +168
- Misses 53614 53623 +9
- Partials 18091 18098 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kosiew
marked this pull request as ready for review
July 31, 2026 11:11
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
Rationale for this change
Grouped hash aggregation currently exposes a single
aggregate_arguments_timemetric for all aggregate argument evaluation. This makes it difficult to determine which aggregate expression is responsible for argument evaluation cost when multiple aggregates are present (for example,SUM(a)versusSUM(b)).This change adds per-aggregate argument evaluation metrics while preserving the existing operator-level metric for compatibility.
What changes are included in this PR?
Add an
AggregateArgumentMetricshelper that registers one timer per aggregate expression during operator construction.Label per-aggregate metrics using the aggregate expression display text (or alias), allowing otherwise identical aggregate functions on different inputs (for example,
SUM(a)andSUM(b)) to be distinguished.Wrap aggregate argument evaluation with the corresponding per-aggregate timer in:
Introduce
OrderedAggregateTableMetricsto carry both group-by and aggregate argument metrics through ordered aggregation replay/spill paths.Factor out a reusable
aggregate_metric_labelhelper for consistent metric labels.Preserve the existing
aggregate_arguments_timemetric so whole-phase timing continues to be reported.Are these changes tested?
Yes.
This PR adds and updates tests including:
test_groupby_aggregate_argument_metrics_distinguish_inputs, which verifies that separate metrics are created forSUM(a)andSUM(b)with distinct metric names and aggregate labels.Existing group-by metrics tests updated to use shared aggregate construction helpers.
Grouped hash aggregation stream tests updated to verify both:
aggregate_arguments_timemetric remains present and non-zero, andagg_expr_0_arguments_time) is emitted and records time.Are there any user-facing changes?
Yes.
EXPLAIN ANALYZEand execution plan metrics for the covered grouped hash aggregation paths now include per-aggregate argument evaluation timers (for example,agg_expr_0_arguments_time) with aggregate labels identifying the corresponding aggregate expression, while retaining the existingaggregate_arguments_timemetric for compatibility.LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.