Repository navigation
Make query_plan_use_logical_join_step setting obsolete - #104017
Conversation
|
Workflow [PR], commit [32ee3fd] Summary: ❌
AI ReviewSummaryThis PR makes Findings
Tests
Final Verdict
|
8ef2929 to
d4b469e
Compare
Algunenano
left a comment
There was a problem hiding this comment.
The error in performance test is related. Also, was the performance issue fixed (one_thousand_joins) for query_plan_use_logical_join_step=1?
I also noticed that runtime filters, which can only be used with logical joins, can increase query execution time to tens of seconds because we generate too many of them. I think we can address this by limiting the probe size, so runtime filters are not used for cases with small tables. We could also limit the number of runtime filters in the plan, although I'm not sure whether that would still make sense for queries with larger datasets. In this PR, I disabled runtime filters for the test. I will add the limit in #104860. |
Makes sense. We can do another iteration of analysis optimization around it in the future if we need to |
|
@vdimir I just tested with master (LTO from CI and local built without it) and the query from |
Yes, I mentioned it in my comment above, reason for this is runtime filters are enabled by default with |
…ery_plan_use_new_logical_join_step = 0
…oin_using_legacy_step
1dcd838 to
8f587e8
Compare
| @@ -1,71 +0,0 @@ | |||
| -- Tags: use-rocksdb | |||
There was a problem hiding this comment.
Removing this test drops the only focused regression coverage for LowCardinality-wrapped key equivalence when choosing DirectKeyValueJoin for EmbeddedRocksDB joins.
That behavior is still live after this PR: JoinStepLogical still calls chooseJoinAlgorithm, which still uses tryDirectJoin and its recursiveRemoveLowCardinality checks. Existing 04201_direct_join_type_mismatch_rocksdb coverage validates type mismatch fallback, but it does not cover the LowCardinality(String) primary-key equivalence path from this test.
Please keep this scenario on the always-on logical planner path (drop obsolete setting toggles, but keep the LowCardinality PK + explain assertions), otherwise a regression here can silently demote direct lookups to HashJoin with no test signal.
There was a problem hiding this comment.
For new planner hash join is chosen on type mismatch, not sure which is correct, I will change it in another pr if it will work well #105057
There was a problem hiding this comment.
Re-checking current HEAD, this concern is still live.
The deleted test covers the equivalence path (LowCardinality(String) storage PK vs plain String right key), not the type-mismatch path. The behavior is still active in the always-on logical planner because JoinStepLogical still reaches tryDirectJoin, and tryDirectJoin still relies on recursiveRemoveLowCardinality when deciding whether to keep DirectKeyValueJoin.
04201_direct_join_type_mismatch_rocksdb validates mismatch fallback and matching plain types, but it still does not cover LowCardinality PK equivalence. So this regression surface currently has no focused test protection.
Please keep one focused EmbeddedRocksDB test for this LowCardinality-equivalence scenario on the always-on path (without obsolete setting toggles).
LLVM Coverage Report
Changed lines: 100.00% (60/60) · Uncovered code |
When the bounds of a range predicate on a MergeTree primary or partition key arrive through `JOIN ON` against a single-row constant side, the logical join step left the inequality as a residual filter ABOVE the join, where index analysis never sees it. Every part was read. Reported as ClickHouse#112586: on a ~365M-row table this was 1.4s versus 35-68s. Until 26.5 the `query_plan_use_new_logical_join_step` setting could restore pruning; ClickHouse#104017 made it obsolete, leaving no mitigation. Such a condition is now retried against a clone of itself with the opposite side's references replaced by the constants its input header carries. That makes it single-sided, so the existing path places it below the join and `KeyCondition` sees it. The substitution is declined unless it is provably safe: - only INNER, CROSS and comma joins with ALL strictness, where the residual is equivalent to a filter over the product; - never a key-forming equality, including one nested in a disjunction, so a join cannot become keyless and degrade to a product; - constness is read from the header column, so a one-row table stays unpruned; - duplicate column names resolve by source relation and header position, not by name; - every node must be safe to relocate: no stateful or non-deterministic function, no `arrayJoin`, and no function that can throw or is expensive. Below the join a predicate also sees the rows a surviving key rejects, so `ON t.k = b.k AND intDiv(1, t.x) >= b.lo` would raise ILLEGAL_DIVISION on an unmatched row that master answers. Safety is read from `isSuitableForShortCircuitArgumentsExecution`, the property short-circuit evaluation already consults to keep such arguments unevaluated. One behaviour change: a relocatable inequality-only `ON` against a constant side is now answered on the non-hash algorithms instead of raising INVALID_JOIN_ON_EXPRESSION, since the predicate is enforced below the join and no key is needed. Literal bounds already answered, so this removes an inconsistency. A predicate the guards decline keeps raising as before. Nine pruning assertions flip without the fix and each guard is mutation-tested both ways. An A/B sweep of 1195 join and index tests found no difference from pristine master. The stateless test is tagged `no-parallel-replicas`: there the `ON` clause is re-serialized as SQL for the remote legs, so the opposite side is a temporary table rather than a plan-time constant and the plan under test never forms, measured identical on master. Closes ClickHouse#112586.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Setting
query_plan_use_logical_join_step(and its aliasquery_plan_use_new_logical_join_step) is now obsolete and has no effect; the logical join step is always used.Documentation entry for user-facing changes
Version info
26.5.1.806