Repository navigation
Conversation
|
Workflow [PR], commit [c6b4076] Summary: ❌
AI ReviewSummaryThis PR makes sharded PR Metadata
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Minimum required actions: fix the external aggregation/default-on contract, handle or reject |
| - [GROUP BY optimization](/sql-reference/statements/select/group-by#group-by-optimization-depending-on-table-sorting-key) | ||
| )", 0) \ | ||
| DECLARE(Bool, enable_sharding_aggregator, false, R"( | ||
| DECLARE(Bool, enable_sharding_aggregator, true, R"( |
There was a problem hiding this comment.
Turning this on by default changes memory/rollout semantics for users who set external aggregation limits. The sharded path still unconditionally clears params.max_bytes_before_external_group_by in AggregatingStep::transformPipeline, and the existing tests assert that max_bytes_before_external_group_by / max_bytes_ratio_before_external_group_by are ignored on this path. With this default, a query that previously spilled can now choose sharded aggregation and run fully in memory unless the user knows to disable enable_sharding_aggregator.
Please either keep this default false, or make canUseShardedAggregation reject the path when external aggregation is requested, and update SettingsChangesHistory plus the changelog text if the default really changes.
|
📊 Cloud Performance Report 🟢 AI verdict: This PR enables the sharded GROUP BY aggregator by default and reworks the sharded-aggregation pipeline (skew-aware hot/cold key routing). ClickBench Q4 is aggregation-bound, so the -18.25% improvement is directly on-path and plausible — it's a large, consistent shift confirmed by both tests. No regressions flagged; the verdict stands as an aggregation-path win. clickbench🟢 1 improved Flagged queries (1 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
| } | ||
| else | ||
| { | ||
| if (!params->aggregator.executeOnBlock( |
There was a problem hiding this comment.
ColdShardAggregatingTransform is now used for the raw side of sharded aggregation even when AggregatingStep::requestOnlyMergeForAggregateProjection has set params.only_merge for a full aggregate-projection read. In that mode the input columns are already aggregate states, and the normal AggregatingTransform switches to mergeOnBlock; this cold path always calls executeOnBlock, so a projection-backed query can feed AggregateFunction(...) state columns to ordinary aggregate functions or aggregate them as raw values. Please either make canUseShardedAggregation reject params.only_merge, or call mergeOnBlock here when params->params.only_merge is true.
| { | ||
| if (has_pending) | ||
| { | ||
| const size_t num_rows = pending_chunk.getNumRows(); |
There was a problem hiding this comment.
Rows consumed on this cold branch are invisible to rows_before_aggregation. QueryPipeline::initRowsBeforeAggregation only attaches the counter to AggregatingTransform and AggregatingInOrderTransform, so with sharded aggregation enabled the statistic counts only rows routed through the merge path and misses cold rows. For high-cardinality non-hot input that can report 0 even though this transform aggregated the whole query. Please wire the counter into ColdShardAggregatingTransform and add num_rows for non-merge input chunks, or count before the sharder so every source row is included exactly once.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 465/490 (94.90%) · Uncovered code |
|
Architecturally, this algorithm cannot beat the baseline regardless of any missing optimizations. |
Builds on top of:
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Optimizes the sharded aggregation for skewed data. While sharding, hot keys (the few that dominate the data) are detected on the fly and spread across all threads instead of overloading a single shard, while the remaining cold keys are still sharded by hash and aggregated without a merge phase. This keeps
GROUP BYparallel even on heavily skewed data or queries with very few distinct keys, which the initial sharded aggregation handled very poorly. Controlled by the sameenable_sharding_aggregatorsetting which is disabled by default.