Skip to content

Merge filters into join during join reordering - #107637

Open
vdimir wants to merge 51 commits into
masterfrom
vdimir/join_reorder_merge_filters
Open

vdimir wants to merge 51 commits into
masterfrom
vdimir/join_reorder_merge_filters

Conversation

@vdimir

@vdimir vdimir commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

  • Added a new setting query_plan_merge_filters_into_join that allows merging Filter steps into the JOIN step during join reordering, so WHERE predicates participate in join order optimization

Workflow [PR]
Sync PR [sync-upstream/pr/107637]

@clickhouse-gh

clickhouse-gh Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2ed9a1e]

Summary: ❌

job_name test_name status info comment
Style check FAIL
settings_changes_history FAIL cidb
cpp FAIL cidb
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL
Code Review DROPPED
Build (amd_asan_ubsan) DROPPED
Build (arm_asan_ubsan) DROPPED
Integration tests (amd_asan_ubsan, db disk, targeted) DROPPED
Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 16, 2026
@vdimir
vdimir force-pushed the vdimir/join_reorder_merge_filters branch from 2cd92e6 to ea8151b Compare June 18, 2026 14:40
@vdimir
vdimir force-pushed the vdimir/join_reorder_merge_filters branch from 9b27ecd to 698a3fd Compare June 23, 2026 10:44
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 3 query(s) improved out of 37 analysed

This PR overhauls the join-order optimizer — reworking selectivity, cardinality and cost estimation, adding equi-join vs. cross-product handling, and introducing query_plan_merge_filters_into_join. The three flagged TPC-H improvements (Q4 ×3.6 faster, Q7 ×7.5 faster, Q9 -20.4%) are all multi-table joins and align directly with better join ordering; Q7 and Q9 are clean, on-path wins, while Q4's magnitude carries some caution because that query's history is noisy. The two ClickBench deltas (Q4 -10.2%, Q15 -17.2%) are single-table queries with no joins and flat CPU time, so they cannot be caused by this join-only change; the deterministic no_change/envelope suppression is correct there.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 3 improved

Flagged queries (3 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 4 improvement 1026 281 ×3.6 faster <0.0001 plan_change: Q4 is join-heavy and this PR rewrites join-order selectivity/cardinality and cost estimation, so ×3.6 faster is plausibly a better plan; history is flaky, so treat the exact magnitude with some caution.
🟢 7 improvement 552 74 ×7.5 faster <0.0001 plan_change: Q7 joins six relations, exactly the multi-way case this PR retargets with equi-join detection and cross-product avoidance; ×7.5 faster with low-variance measurements is a clear, on-path win.
🟢 9 improvement 108 86 -20.4% <0.0001 plan_change: Q9 is another multi-table join, and the improved cardinality/cost model plausibly reorders it better; -20.4% is a modest but consistent on-path gain.

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.

Debug info
  • StressHouse run: 8ab5dcfe-b4a2-455e-a055-d66fa00eb98a
  • MIRAI run: 86c24213-ddf7-48d3-8dee-49b5a107d4df
  • PR check IDs:
    • clickbench_42277_1784287531
    • clickbench_42283_1784287531
    • clickbench_42295_1784287531
    • tpch_adapted_1_official_42301_1784287531
    • tpch_adapted_1_official_42313_1784287531
    • tpch_adapted_1_official_42325_1784287531

@vdimir
vdimir force-pushed the vdimir/join_reorder_merge_filters branch from 698a3fd to 1c8135d Compare June 24, 2026 13:26
@vdimir
vdimir marked this pull request as ready for review July 6, 2026 12:37
vdimir added a commit that referenced this pull request Jul 6, 2026
…inistic

`04327_correlated_subquery_duplicate_column_join` failed in Fast test with
`LOGICAL_ERROR` "Input nodes size mismatch in dag" thrown from
`JoinExpressionActions` via `chooseJoinOrder`, because the
`joinGraphHasOverlappingColumnNames` guard was temporarily disabled.
Re-enable it.

Also make tests robust to settings randomization and the new default
pretty `EXPLAIN` format:
- `04337_join_reorder_merge_filter_into_join`: pin `explain_query_plan_default`
  to `legacy` - the step-counting queries match plan lines with anchored
  `LIKE` patterns, which the pretty tree format breaks.
- `03734_correlated_subqueries_reorder`: pin `materialize_statistics_on_insert = 1`
  and update `ResultRows` in the reference - CI randomizes this setting, and
  the NDV-based estimate depends on whether statistics are materialized
  (`ResultRows: 100` with statistics vs `10000` from the FK->PK heuristic
  without them).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107637&sha=64d49501ceacdb91de205a56ddc0b42ee8409cc1&name_0=PR&name_1=Fast%20test
PR: #107637

Co-Authored-By: Claude Fable 5 <[email protected]>
@vdimir
vdimir force-pushed the vdimir/join_reorder_merge_filters branch from bc60009 to 81b4da6 Compare July 6, 2026 15:27
@alexey-milovidov

Copy link
Copy Markdown
Member

Updating the branch to fix the 04001_join_reorder_through_expression test, which was broken today in master.

@vdimir
vdimir force-pushed the vdimir/join_reorder_merge_filters branch from 6de4978 to 1f082a4 Compare July 8, 2026 18:39
vdimir added a commit that referenced this pull request Jul 8, 2026
…inistic

`04327_correlated_subquery_duplicate_column_join` failed in Fast test with
`LOGICAL_ERROR` "Input nodes size mismatch in dag" thrown from
`JoinExpressionActions` via `chooseJoinOrder`, because the
`joinGraphHasOverlappingColumnNames` guard was temporarily disabled.
Re-enable it.

Also make tests robust to settings randomization and the new default
pretty `EXPLAIN` format:
- `04337_join_reorder_merge_filter_into_join`: pin `explain_query_plan_default`
  to `legacy` - the step-counting queries match plan lines with anchored
  `LIKE` patterns, which the pretty tree format breaks.
- `03734_correlated_subqueries_reorder`: pin `materialize_statistics_on_insert = 1`
  and update `ResultRows` in the reference - CI randomizes this setting, and
  the NDV-based estimate depends on whether statistics are materialized
  (`ResultRows: 100` with statistics vs `10000` from the FK->PK heuristic
  without them).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107637&sha=64d49501ceacdb91de205a56ddc0b42ee8409cc1&name_0=PR&name_1=Fast%20test
PR: #107637

Co-Authored-By: Claude Fable 5 <[email protected]>
vdimir added a commit that referenced this pull request Jul 13, 2026
…ction

A pair linked only by non-equi predicates was classified the same as a
pure cross product, so once the first predicate-less pair became the
best plan, every later predicate-bearing pair was skipped and greedy
could commit to an unconstrained cross product first.

Keep `connected` meaning "any predicate spans both sides" (as in DPsize)
for the skip rule, and key the supersede rule on an equi connection only.

#107637 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Your PR was poisoned by the test 02346_text_index_bug108519_qcc_skip_index. It is fixed in master. Please update the branch.

Comment thread src/Core/Settings.cpp
Allow to merge expressions into JOIN step during join reordering optimization.
Allow to merge `Expression` steps into JOIN step during join reordering optimization.
)", 0) \
DECLARE(Bool, query_plan_merge_filters_into_join, false, R"(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a new setting needed? There is query_plan_merge_filter_into_join_condition already and it has the same purpose.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change allows building a query graph from a plan with filters; previously, filters acted as a barrier to join reordering.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They act at different stages on different objects, so one cannot replace the other.

query_plan_merge_filter_into_join_condition drives tryMergeFilterIntoJoinCondition, a regular query-plan optimization: it takes a Filter step sitting directly above a JOIN step and moves the condition into that join's ON clause (converting CROSS JOIN to INNER when the condition qualifies). It rewrites one join at a time and is independent of join reordering — it applies even when reordering is off.

query_plan_merge_filters_into_join controls what the join-reordering optimization absorbs into the join graph. When reordering builds a graph out of a chain of joins, Filter steps sitting between those joins would otherwise terminate the chain, so the graph stays small and the predicates never take part in the search. With the setting on, isMergeableStepAboveJoin/mergeStepIntoQueryGraph peel such a Filter and turn its condition into ordinary edges of the graph, which means the enumerator can (a) span the whole join chain instead of stopping at the filter, and (b) use those predicates for selectivity and cardinality estimation while choosing the order — the effect the changelog entry describes. It is the Filter counterpart of the existing query_plan_merge_expression_into_join, and it is named after it for that reason.

So the pre-existing setting cannot express "let WHERE predicates participate in join order optimization": by the time reordering runs, a filter it did not merge is still a plan step that bounds the graph. Conversely this new setting does not subsume the old one, which also handles the CROSS-to-INNER rewrite outside reordering.

If the naming is the concern, I am happy to rename it to something less confusable — e.g. query_plan_merge_filter_into_join_graph, which would say which of the two objects it merges into.

vdimir and others added 5 commits July 30, 2026 12:49
…inistic

`04327_correlated_subquery_duplicate_column_join` failed in Fast test with
`LOGICAL_ERROR` "Input nodes size mismatch in dag" thrown from
`JoinExpressionActions` via `chooseJoinOrder`, because the
`joinGraphHasOverlappingColumnNames` guard was temporarily disabled.
Re-enable it.

Also make tests robust to settings randomization and the new default
pretty `EXPLAIN` format:
- `04337_join_reorder_merge_filter_into_join`: pin `explain_query_plan_default`
  to `legacy` - the step-counting queries match plan lines with anchored
  `LIKE` patterns, which the pretty tree format breaks.
- `03734_correlated_subqueries_reorder`: pin `materialize_statistics_on_insert = 1`
  and update `ResultRows` in the reference - CI randomizes this setting, and
  the NDV-based estimate depends on whether statistics are materialized
  (`ResultRows: 100` with statistics vs `10000` from the FK->PK heuristic
  without them).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107637&sha=64d49501ceacdb91de205a56ddc0b42ee8409cc1&name_0=PR&name_1=Fast%20test
PR: #107637

Co-Authored-By: Claude Fable 5 <[email protected]>
`collectJoinEdgesMask` kept a non-connecting predicate only at
two-relation joins and only when `fromLeft`/`fromRight`/`fromNone`
held, which are hard-coded to source relations {0} and {1}. A filter
merged into the join graph (e.g. by `query_plan_merge_filters_into_join`
from a flattened subquery) whose relation id is >= 2 was attached
nowhere, so `dpsub` silently dropped it from the plan and returned rows
that should have been filtered out. Attach single-relation predicates at
the join step where their relation forms a whole side (the leaf join of
that relation), mirroring the `dpsize` fix, and keep the two-relation
attachment only for constant predicates.

Co-Authored-By: Claude Fable 5 <[email protected]>
`solveDPsize` filtered non-connecting predicates by their raw source
relations, ignoring the null-supplying relation that ON-clause conjuncts
of an outer join are pinned to. A pinned single-table conjunct (e.g.
`t2.value = 'x'` in `... LEFT JOIN t3 ON t2.id = t3.id AND t2.value = 'x'`)
reaching the step that joins the null-supplying relation matched neither
the singleton nor the constant branch and was silently dropped.

Not reachable today: `dpsize` restricts itself to inner join steps, so it
never assembles a plan containing an outer join and falls back instead.
Align the placement rule with `collectJoinEdgesMask` (`sources | pin`)
so the conjunct stays in the outer join's ON condition once that
restriction is lifted, and add a `dpsize` variant of the chained outer
join test that 04507_dpsub_chained_outer_join_null_side covers for
`dpsub`.

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov and others added 3 commits October 25, 2026 03:27
…etector

After merging master, DPsub with the `CD-C` conflict detector is the default join order
algorithm, and it requires every join graph condition to name the join step it comes from
(`edge_conflict_ops`). Conditions merged by `query_plan_merge_filters_into_join` had none, so
DPsub threw `Join graph has N conditions, but join steps are recorded for M of them`, and the
operator indices of all conditions united after them were shifted.

Attribute each merged condition to the root join step of the graph it is merged into, and mark
it as applied above that step (`edge_above_conflict_op`): when it reads the null-supplying side
of the step, DPsub waits for the step itself, so a `WHERE` condition over a flattened
null-supplying subtree is applied to the padded rows after the outer join, not inside the
subtree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`buildPhysicalJoinImpl` collected the inputs of the `ON` and residual conditions by walking every
path of the condition DAG. A condition with shared nodes (a chain of `x + x` aliases) has
exponentially many paths, so `05359_partial_result_shared_nodes_join_filter` hung once
`query_plan_merge_filters_into_join` merged such a filter into the join step. Keep a visited set.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107637&sha=latest&name_0=PR
#107637

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`05055_join_order_greedy_non_equi_over_cross` asserts an exact greedy join order, which changes
with column statistics (randomized `auto_statistics_types`), so disable them for its tables.
`05292_replace_always_true_filter_join_order` checks that only a filter left between the joins
splits the join graph, so pin `query_plan_merge_expression_into_join = 1` and
`query_plan_merge_filters_into_join = 0`, which this PR randomizes.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107637&sha=latest&name_0=PR
#107637

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master and resolved conflicts with the DPsub / conflict-detector work (DPsub with CD-C is now the default):

  • below_null_supplying from master is folded into isMergeableStepAboveJoin: inside a null-supplying input, a Filter step is never merged, and an expression is merged only if it just renames columns.
  • Merged WHERE conditions are now attributed to the root join step of their graph (edge_conflict_ops) and marked as applied above it (edge_above_conflict_op). Before this, DPsub threw Join graph has N conditions, but join steps are recorded for M of them. Covered by 05449_join_reorder_merge_filter_conflict_detector.
  • Fixed the three bot findings (Variant/Dynamic equalities, Join engine keys), with tests in 05448_join_reorder_merge_filter_unsafe_keys.
  • Fixed an exponential traversal in buildPhysicalJoinImpl that made 05359_partial_result_shared_nodes_join_filter hang with this setting on.
  • Pinned settings in 05055_join_order_greedy_non_equi_over_cross (auto_statistics_types) and 05292_replace_always_true_filter_join_order.

Two threads are still open and need a decision from @vdimir: whether to rename the setting (asked by @novikd), and whether to estimate single-table filter selectivity in this PR or in a follow-up.

@clickhouse-gh clickhouse-gh Bot added comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... and removed comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... labels Oct 25, 2026
alexey-milovidov and others added 3 commits November 1, 2026 13:49
…type; visit shared condition atoms once

A merged `WHERE` equality can become a join key; operands that `equals` compares but that have no
common supertype (`DateTime` and `UInt32`) made the join throw `NO_COMMON_TYPE`. Keep such a
filter as a step, like `extractActionsForJoinCondition` does.

Flattening the merged condition into join-graph edges walked every path of the condition DAG,
so a shared conjunction (`p1 = p0 AND p0`, ...) produced exponentially many identical edges.
Track visited nodes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pe and shared condition atoms

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=107637&sha=f8c29792925ea30aaa5e095c1b602137d925441a&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29 (Inconsistent AST formatting for an EXPLAIN ESTIMATE query, STID 1941-1bfa; AST formatting is not touched by this PR) and provide a fix in a separate PR. If the fix is already in progress, link it here.

The Upgrade check failure (use_query_condition_cache_for_time_conditions) was fixed on master by #127687, which is now merged into this branch.

@groeneai

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

The fix is in progress in #120222. This is the same issue as on #112928 (#112928 (comment)): EXPLAIN ESTIMATE and its settings are not involved.

The fuzzed query contains FROM part, LATERAL {fuzz_param_0:Identifier} LOCAL ASOF INNER JOIN (...), where LATERAL is a table name and {fuzz_param_0:Identifier} is its query-parameter alias. The formatter drops that alias and prints LATERAL LOCAL ASOF INNER JOIN, so the re-parse takes LOCAL as the implicit alias of LATERAL instead of the join locality. Minimal: SELECT 1 FROM t1, LATERAL {p:Identifier} LOCAL ASOF INNER JOIN t2 ON 1.

Measured with debug builds of master 808fe40f2c5: without the change, the original query and the minimal one both abort at the formatting check; with the #120222 parser change, both pass it (and then fail only with Code: 456 for the unset parameter). The dropped alias itself is handled in #110833. #120222 has not been reviewed yet.

alexey-milovidov and others added 3 commits November 9, 2026 16:33
# Conflicts:
#	src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
…n chain

A `WHERE` condition computed by a separate `ExpressionStep` below the `Filter` step
(e.g. with `query_plan_merge_expressions = 0`) hid an unsafe equality from
`hasEqualityUnsafeAsJoinKey`, which only inspected the filter's own DAG. The check now
runs in `peelMergeableStepsAboveJoin` over the expression steps below each filter too,
and `addChildQueryGraph` uses the same function, so the peeled chain stops at the
topmost unsafe filter.

Also treat the null-safe `isNotDistinctFrom` like `equals`: physical planning consumes
it as a join key as well, and its key matching differs (a NaN matches another NaN).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A predicate DAG with shared conjunction nodes (`p1 AND p1` where `p1 = p0 AND p0`)
made `extractConjunctionAtoms` yield exponentially many copies of the same atoms.
With `query_plan_optimize_join_order_limit = 1` (randomized in CI) the filter push-down
over a join then spent minutes in `filterResultForNotMatchedRows`, which made
`05480_join_reorder_merge_filter_no_common_type_shared_atoms` exceed the time limit in
the flaky check. Cover that path in the test too.

https://s3.amazonaws.com/clickhouse-test-reports/PRs/107637/6d705238f9aec3f5178777997cee5b0c61703af9/pr/result_pr.json
Related: #107637

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai — the AST fuzzer failure (LATERAL alias dropped by the formatter) is tracked by #120222 and is unrelated to this PR.

Update in 73a6662: merged master (resolved a conflict in optimizeJoin.cpp with the null_supplying_relations type-change handling); the join-key safety check now also covers the expression steps below a merged filter and isNotDistinctFrom (new test 05616_join_reorder_merge_filter_unsafe_keys_expression_chain); and ActionsDAG::extractConjunctionAtoms now visits shared nodes once — it produced exponentially many atoms for 05480's shared-conjunction query when query_plan_optimize_join_order_limit = 1, which caused the flaky-check timeouts. The 05474_parquet_corpus_writers failure is fixed on master (e514655) and comes in with the merge.

Comment thread src/Interpreters/ActionsDAG.cpp Resolved
nickitat and others added 3 commits November 14, 2026 13:56
# Conflicts:
#	src/Processors/QueryPlan/JoinStepLogical.cpp
#	src/Processors/QueryPlan/Optimizations/joinOrderDPSize.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
@nickitat

Copy link
Copy Markdown
Member

🕵 Merged master into this branch and resolved the conflicts caused by #129617 (the switch to the -WithMemoryTracking containers). I also added a small commit that switches the new code to the -WithMemoryTracking types where it meets the APIs changed there, so that it compiles. This update was made automatically.

@clickhouse-gh clickhouse-gh Bot added comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... and removed comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... labels Nov 19, 2026
alexey-milovidov and others added 3 commits November 23, 2026 23:56
…alities unsafe as join keys

`peelMergeableStepsAboveJoin` checked only the chain of steps above the nearest join. The condition of
a `Filter` step can also be computed below that join, by a step that `buildQueryGraph` flattens into the
same graph afterwards, so the merged filter read the resolved equality and it became a hash join key:
extra rows for `Variant` and NaN with `isNotDistinctFrom`, `ILLEGAL_COLUMN` for `Dynamic`, and
`NO_COMMON_TYPE` for `DateTime` and `UInt32`.

The new `hasEqualityUnsafeAsJoinKeyInSubplan` walks every `Expression`, `Filter`, and `JoinStepLogical`
step below the chain, which covers at least what the graph can absorb, and a filter above such an equality
keeps its step.

#107637 (comment)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…filter into atoms

`ActionsDAG::extractConjunctionAtoms` visits a shared node once, but it walked the arguments of `and`
right to left, so it kept the last occurrence of a repeated atom: `notEmpty(s) AND toInt32(s) > 0 AND
notEmpty(s)` became `toInt32(s) > 0 AND notEmpty(s)` after filter push down, and the conversion ran
before its guard. It now walks left to right, keeps the first occurrence, and reverses the result to
keep returning the atoms right to left.

`mergeStepIntoQueryGraph` had the same traversal for the filter merged into the join graph
(`query_plan_merge_filters_into_join`), and the edges kept that reversed order in the rebuilt join
condition. It now visits the conjuncts in the written order too.

#107637 (comment)
#107637 (comment)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master (no conflicts) and addressed the remaining review threads:

  • d0a18ad: the join-key safety check for a merged Filter now covers the whole subplan below it, including expressions computed below an intervening join (Variant, Dynamic, DateTime / UInt32, isNotDistinctFrom with NaN). Test: 05872_join_reorder_merge_filter_unsafe_keys_below_join.
  • 2ed9a1e: ActionsDAG::extractConjunctionAtoms and mergeStepIntoQueryGraph keep the written order of conjuncts and the first occurrence of a shared atom, so a throwing conversion no longer moves before its guard. Test: 05873_join_reorder_merge_filter_conjunct_order.

The previous CI run was red only because of the review-threads gate (the full suite was skipped). One thread is still open and needs a decision from @vdimir: whether to rename query_plan_merge_filters_into_join (asked by @novikd).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only equals conjuncts are merged into a JOIN condition, so a cross-table range comparison never reaches join planning: TPC-DS query_72 -86%

7 participants