Repository navigation
Conversation
|
Workflow [PR], commit [d98b3ba] Summary: ✅
AI ReviewSummaryThis PR moves optimized Final Verdict✅ Approve. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 13/14 (92.86%) · Uncovered code |
298cd25 to
a2357ec
Compare
|
📊 Cloud Performance Report ✅ AI verdict: This PR only changes how result-row and column statistics propagate through logical joins in the join-order optimizer, so it affects plans that contain joins. The three flagged ClickBench queries (Q18, Q31, Q34) are single-table aggregations with no joins and cannot exercise the changed path; their +6-11% deltas all fall inside master's current variance band, so the deterministic envelope suppression is correct and these are noise, not regressions. Notably the join-heavy tpch_adapted_1_official benchmark, which is what this change actually targets, produced no flagged queries. No real performance regression is attributable to this PR. clickbenchFlagged queries (3 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. 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
|
Retain join NDV propagation on top of the unconditional public exchange traversal. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114614&sha=b9c914c8997b6609c9f345100dfc255a8bc6f69c&name_0=PR&name_1=Fast%20test PR: ClickHouse#114614
Reapply only the join NDV propagation and expected plan update on top of current master. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114614&sha=b9c914c8997b6609c9f345100dfc255a8bc6f69c&name_0=PR&name_1=Fast%20test PR: ClickHouse#114614
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes9 object files changed (+32.72 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units7 translation units recompiled, 23 s compile time in total, 7 of them have a recent master baseline. |
| return aggregation_stats; | ||
| } | ||
|
|
||
| if (const auto * join_step = typeid_cast<const JoinStepLogical *>(step); join_step && join_step->isOptimized()) |
There was a problem hiding this comment.
The same fix was already attempted #97114 and was reverted in #99957 because of perf regressions https://github.com/ClickHouse/clickhouse-private/issues/52864
A more robust fix is investigated here #101398
Base-table NDV can exceed the row count of a multi-relation join input, so `1 / max(NDV)` underestimates the output of the join above it and the optimizer picks a worse order. Cap each join key NDV and NDV upper bound by the estimated rows of its input subtree when that side contains more than one relation. `SelectivityCache` stores context-independent `JoinKeyStats` instead of a finished `SelectivityEstimate`: the same edge can join different subtrees in another candidate plan, so the row cap is applied after the cache lookup. Both direct predicates and transitive equivalence classes are covered in `dpsub`, `dphyp`, `dpsize`, and `greedy`. Tests: `05493_join_order_subtree_ndv` checks corrected estimates, cache contexts, and bushy plans. `05494_join_order_subtree_ndv_stable` uses independent tables per algorithm to verify cold and warm `EXPLAIN` plans are identical with hash table statistics enabled. Historical benchmark (7 runs, discard the first, median of the remaining 6; result hashes identical): TPC-DS Q72 0.1725s -> 0.0835s. TPC-H Q02 unchanged at 0.034s. These figures come from the original benchmark logs and were not rerun for this commit. Related: ClickHouse#128102 Related: ClickHouse#114614 Related: ClickHouse#101398
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Preserve NDV statistics across optimized inner joins so distributed planning can choose partial aggregation for low-cardinality GROUP BY queries instead of shuffling all joined rows.
Description
An optimized
JoinStepLogicalhas two children, soestimateReadRowsCountreturned before reading its saved result-column statistics. Move the optimized-join handling before the generic single-child guard so row estimates and column statistics propagate to downstream planning.The regression test verifies that a low-NDV GROUP BY after an inner join selects partial aggregation. It pins the join-order limit and distributed aggregation mode to isolate the planner behavior from injected settings and exchange execution details.
Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/114614]