Repository navigation
Extend outer to inner join conversion - #120253
alexey-milovidov merged 13 commits into
Conversation
|
Workflow [PR], commit [163a69f] Summary: ✅
AI ReviewSummaryThis PR adds a second-pass optimizer that converts Final Verdict✅ No actionable findings in the current revision. LLVM Coverage ReportMeasured on commit 163a69f.
Changed lines: Changed C/C++ lines covered: 305/320 (95.31%) · Uncovered code |
| /// arbitrarily higher in the plan (a filter, or the conditions of an enclosing INNER/SEMI join). | ||
| /// This pass is complementary to `tryConvertOuterJoinToInnerJoin`, which only sees the filter directly | ||
| /// above but handles all filter shapes where this one matches a subset. | ||
| void convertOuterJoinToInnerJoinTransitively(const QueryPlanOptimizationSettings & optimization_settings, QueryPlan::Node & root); |
There was a problem hiding this comment.
Why is it implemented as a separate optimization, not as an extension of convert_outer_join_to_inner_join? Why is it implemented as a second path optimization?
Transitivity for convert_outer_join_to_inner_join could be guaranteed by filter push down, so separate optimisation looks like an overkill
There was a problem hiding this comment.
Are you referring to deriving col IS NOT NULL filters from the upper INNER join and letting filter pushdown drive them to above the OUTER join for the exiting convert_outer_join_to_inner_join to handle them?
That would be the first implementation I had, details #114817. But removing the added filters from the plan after the conversion was done was messy.
There was a problem hiding this comment.
At least we have a feature flag. This is good.
…er-join-conversion Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. - retargeted PR record [email protected] to 26.10 (settings-history check rule) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes897 object files changed (+328.71 KiB total), 1 added.
716 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 units1341 translation units recompiled, 8391 s compile time in total, 1340 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. Translation units without a recent master baseline:
|
alexey-milovidov
left a comment
There was a problem hiding this comment.
Fantastic optimization. Love it!
Re-implements: #114817
Related: #119275
Related: #119305
Related: #120119
Related: #120130
closes: #112456
Extends OUTER join to an INNER join conversion.
The existing
query_plan_convert_outer_join_to_inner_joinonly looks at a filter that is the direct parent of the join:converts to
After the change the following cases are also supported:
converts to
converts to
How it works: the pass walks the plan top down, carrying the set of columns that cannot be NULL in a row that reaches the result.
WHERE e.grade > l.min_gradeaddse.grade, andON e.lecture_id = l.idon an INNER join addse.lecture_id. When the walk reaches an outer join and any column in the set comes from the side that join fills with NULLs, those rows are dead and the join kind is downgraded.This replaces the approach of #114817, which derived IS NOT NULL filters and inserted marker steps into the plan. That was reverted because other optimizations could interact with the derived filters (move or split). This new design derives no filters and inserts no steps so it's less error prone. It also handles more cases like stranded filters higher in the plan.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
OUTER JOIN queries can now be faster: when a WHERE clause or another JOIN later in the query would discard the unmatched rows anyway, ClickHouse converts the join to an INNER JOIN. The new setting
query_plan_convert_outer_join_to_inner_join_transitivelycontrols this, and only takes effect whenquery_plan_convert_outer_join_to_inner_joinis enabled.Workflow [PR]
Sync PR [sync-upstream/pr/120253]
Version info
26.10.1.1251-master(included in26.10and later)