Repository navigation
Conversation
…l ON condition A hash join with several `ON` disjuncts, or with an additional `ON` condition such as `l.x < r.y`, looked one left row up in the table of each disjunct in turn (`HashJoinTable::probeAll`, `detail::probeAllRows`). Now it takes a batch of left rows, looks all of them up in the first table, then in the next one, and then adds the matches of the batch. A join that stops at its first match looks a later table up only for the rows that no earlier disjunct matched. This removes `HashJoinTable::probeAll`, `detail::probeAllRows` and `MultiMapLookupSampler`. The key search (`LookupMethod.h`, `FindKeys.h`, `FindKeysMaps*.cpp`), the batch driver (`JoinRightColumns.h/.cpp`) and the match steps `addMatchesOfDisjuncts` and `addMatchesWithAdditionalFilter` (`JoinRightColumnsImpl.h`) are ported from commit c1ab44b of ClickHouse#130344 by harikrishnan94, cut to these two shapes of join: none of the one-disjunct probe of that commit is taken (`MatchAdder`, search batches, fused loops), so a join with one disjunct and no additional condition keeps `HashJoinTable::probe`, and only loses the `flag_per_row` template parameter of `processMatch` and `joinRightColumns`. `KnownRowsHolder.h` is that commit's version. Related: ClickHouse#120515, ClickHouse#130344 Co-authored-by: harikrishnan94 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
`joined_block_split_single_row`, which the test runner randomizes, rejects `max_joined_block_size_rows = 0`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A probe column built as `intHash64(number + c)` is the previous column one row later, so the key of one disjunct predicts the key of the next disjunct one row on, which a loop over the disjuncts of a row can exploit. Hash `number * 32 + c` instead, so that every column has its own hash. Also add rows whose disjuncts all match together or none does, with an ALL join over three disjuncts and an ANTI join over two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings; 1 full pass).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261119-064200 |
groeneai
marked this pull request as draft
November 19, 2026 07:11
Collaborator
Author
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261119-052300 |
Contributor
|
Workflow [PR], commit [b0bf917] Summary: ❌
|
Contributor
|
Not needed. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #120515
Related: #130344
Related: #132628
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A hash join with several
ONdisjuncts, or with an additionalONcondition, now looks up a batch of left rows in the table of each disjunct in turn, instead of one row at a time in every table.Description
Draft, as asked in #120515 (comment).
A hash join with several
ONdisjuncts, or with an additionalONcondition such asl.t < r.t, looked each left row up in the table of every disjunct in turn (HashJoinTable::probeAll). Now it looks a batch of left rows up in each table in turn, then adds their matches. A join that stops at its first match looks a later table up only for the rows still unmatched.The key search (
LookupMethod.h,FindKeys.h,FindKeysMaps{All,One,Set}.cpp),KnownRowsHolder.h, the batch driver (JoinRightColumns) and the match stepsaddMatchesOfDisjunctsandaddMatchesWithAdditionalFilterare the code of commitc1ab44bb9559(#130344). Its one-disjunct probe (search batches,MatchAdder, fused loops,WordsAndKeyOffsets, ASOF key search) is not taken, so a join with one disjunct and no additional condition keepsHashJoinTable::probe.Performance, ratio PR / master
6483b80at 16 and 96 threads (x86 release, Xeon 6975P-C, one socket,parallel_hash, 60M left rows, table). Slower: ALL with 2 to 4ORout of cache 1.04 to 1.13, withNullablekeys 1.08 to 1.12, LEFT SEMI and ANTI with a rarely matching first disjunct in cache 1.03 to 1.11, rows whose disjuncts all match or none 1.18 to 1.30. Faster: LEFT ANY and SEMI with an often matching first disjunct 0.73 to 0.92, ALL with 3 or 4ORin cache 0.76 to 0.92. #132628 is slower than its merge base in the same cases by about as much (table), so the performance bar of the request is not met yet.Tests:
05823_hash_join_probe_disjunct_batchesruns 40 joins on left blocks of 1000 to 20001 rows and row limits 7 and 1000, each giving master's result. The performance testhash_join_or_disjuncts_batched_probe.xmlruns these cases out of cache.Workflow [PR]
Sync PR [sync-upstream/pr/132896]