Repository navigation
Conversation
Let `tryMergeFilterIntoJoinCondition` extract cross-side range comparisons (`<`, `<=`, `>`, `>=`) when `hash` is enabled, guarding each conjunct against evaluation-count sensitivity and `ARRAY_JOIN`. Also let `isIEJoinPreferred` yield to another runnable algorithm when a cross-side equality key matches values `equals` rejects (`NaN`, `NULL`s inside tuples) and all equality keys have a valid common type.
|
Workflow [PR], commit [e382871] Summary: ❌
AI ReviewSummaryThe PR promotes safe cross-side range predicates from Findings
Performance & SafetyAll changed
Tests
Final Verdict |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1408 translation units recompiled, 34 s compile time in total, 1408 of them have a recent master baseline. |
A range such as `toInt64` or a `Decimal` compared with `Float64` can throw, and a residual `rowNumberInAllBlocks` changes when rows are removed first. Pin `query_plan_merge_filter_into_join_condition` where an EXPLAIN reference depends on it.
`canBeMovedToTheFrontOfAndChain` already decides that an `and` atom can run on more rows, and `isSensitiveToEvaluationCount` with `hasArrayJoin` already guards a step that changes the row set.
A single top-level `or` is the hash-key form for disjunctive `ON`. Appending another conjunct would turn those keys into scalar `equals`.
Treat nested Variant, Dynamic and JSON types as potentially throwing in comparisonCanThrow, so a promoted comparison cannot run before its guarding conjunct. Do not extract range predicates when the existing JOIN expression is sensitive to evaluation count. Add regression coverage for both cases to 05454.
…er-into-join test. `less` is cheap, so when the flaky check disables `query_plan_merge_filters` it runs before a false guard and throws `NO_COMMON_TYPE`.
Those checks apply to conditions already written in `ON`, so they belong with the standalone `ie_join` fix. Range merging still keeps Tuple and Float equalities in the residual filter.
…o filter-into-join Take master's from and its handling in instead of the copies in this branch.
ClickHouse#129219 concluded that `ie_join` should not yield to another algorithm when a residual `equals` differs from a join key: the remaining differences (`NaN`, `NULL` inside tuples) are documented per algorithm in ClickHouse#129361, and ClickHouse#118561 makes `String`/`FixedString` keys, including `ie_join` range keys, compare like the scalar functions. The `hash` requirement for merging ranges now states its actual reason: a merged range is a non-equi `ON` condition. Add the `String`/`FixedString` regressions from the review of ClickHouse#128140, and drop the `parallel_hash` case: `parallel_hash` is now the same algorithm as `hash`. Related: ClickHouse#129219 Related: ClickHouse#128140
Drop the `String`/`FixedString` cases (fixed in master by ClickHouse#118561), the `NaN`/`Tuple(Nullable)` key cases (documented per algorithm in ClickHouse#129361), and the reorder cases that repeat one query under other join or reorder algorithms. Shorten the comment of the performance test.
| || conjunct->function_base->getName() == "greater" | ||
| || conjunct->function_base->getName() == "greaterOrEquals") | ||
| && conjunct->children.size() == 2; | ||
| if (!block_range_predicates && is_range && is_cross_side(conjunct->children[0], conjunct->children[1]) |
There was a problem hiding this comment.
[Major] Recheck the repeatable TPC-DS Q72 slowdown on the current head
The existing tpcds query index 71 (Q72) exercises these cross-side ranges together with additional outer joins. It slows down on ARM in all four completed PR comparisons: +11.3%, +9.7%, +9.0%, and +10.0%. In the latest measured run, client_time rises from 0.1148 s to 0.1263 s; repeated samples and recent master variation support a slowdown signal. The new focused benchmark shows a substantial improvement, but its join graph omits these outer joins.
These measurements cover 9806d0140620 and earlier commits, so they do not establish a regression at the current head. Please rerun this query on e382871ec866 against its current base and compare the plans/profiles if the slowdown persists. The performance claim needs this existing workload accounted for before approval.
Motivation
A cross-side range comparison written in
WHERE(<,<=,>,>=) used to stay in aFilterStepabove the join. The join-order optimizer walks throughJoinStepLogical, and stops at that filter, so the join underneath is one relation. Equalities were already pulled into the join byquery_plan_merge_filter_into_join_condition; ranges were not.aandcare 3 rows each, andbis 10 000 rows. With the ranges stuck above the joins, the plan joinsbfirst and appliesa.x < c.x AND a.y > c.yonly after both joins. After the ranges become join conditions, reordering joinsaandcfirst and then joinsbto that result.Example SQL and Plan Change
Before:
After:
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Cross-side range comparisons (
<,<=,>,>=) inWHEREare merged into anINNERorCROSSjoin whenquery_plan_merge_filter_into_join_conditionis enabled, so the join-order optimizer can reorder across them.Workflow [PR]
Sync PR [sync-upstream/pr/128140]