Repository navigation
Faster hash joins on wide multi-column keys and String mixes - #129328
Conversation
|
Workflow [PR], commit [7b748c7] Summary: ✅
AI ReviewSummaryPR #129328, reviewed at Missing context / blind spots
Final VerdictStatus: ✅ Approve — no review findings; pending CI must still pass. |
34d9342 to
c4bada7
Compare
`PreparedJoinKeys` is a base for the hash join key getters that can build the keys of many rows in one call, for example to hash several keys at a time. No key getter uses it yet, so the joins behave as before. When a parallel build scatters the rows of a right block to its slots, a key getter with this base builds the key of each row once, with `buildAllKeys`, and the scatter takes the slot from the bucket of that key. The slot inserts read these keys through a new parameter of `HashJoinMethods::insertFromBlockImpl`. Otherwise the scatter and the slot insert would each build the key of every row. The other join loops call the key getter's `prepareRows` before they read any key. For a continuous range of rows, the key getter then builds the keys 256 at a time, each time a read passes the keys built so far. Before it builds the next keys, it keeps only the last 32 keys built so far. A loop reads the rows in order, and its lookups trail its prefetch reads by at most 32 rows, so no loop reads a dropped key. The loops make these calls only under `if constexpr`, so the code for the other key getters does not change. Some loops read the rows of a block through a list of row numbers. For example, an ASOF join whose ASOF column is `Nullable` drops the right rows with a `NULL` there, so its build reads the other rows through such a list. Without prepared keys, a prefetching loop would build each key twice: once for the prefetch and once for the insert. When the list is in ascending order, the key getter builds the keys of all the rows from the first listed row to the last one, and passes the rows that are not listed as skipped, so that it does not have to build their keys. It builds them all at once, not 256 at a time, because the rows left out can make the look-ahead of a prefetching loop span more than the 32 keys kept between chunks. For a list in any other order, the key getter builds each key where it is read. A loop that uses software prefetch builds each key once, for both the prefetch and the lookup. A loop skips the rows with a `NULL` key or a false `ON` condition, and it does not prefetch them. It passes skip bytes that mark these rows to `prepareRows`, so that the key getter does not build their keys. After a run of 256 or more skipped rows, the next chunk of keys covers the whole run and the row after it. When a block has no such rows, the skip bytes are all zero. So a loop that checks for skipped rows tests one byte per row. A key getter needs no separate code for a block without skipped rows. The build tests this byte instead of the `NULL` map and the `ON` mask. The build skips a row with a `NULL` key. As with the other key getters, such a row still keeps its right block in memory. For a map that stores one row per key, each slot insert looks for such rows in the `NULL` map once, before its loop. The other maps keep every block anyway. The scatter of a parallel build routes every row by its key, so `buildAllKeys` builds the keys of the skipped rows too. A join with `OR` and a condition in `ON` looks up every row that it does not skip in every map, so it prepares the keys of every map. Any other join with `OR` prepares the keys of its first map, and with prefetch also those of each other map that it prefetches for every row. When such a join stops at the first match, it prefetches its later maps only while enough sampled rows reach them. It prepares the keys of such a map when it starts to prefetch the map. When it stops, the map builds each key where it is read again, because few rows read it. When the keys are inconsistent, the join throws `LOGICAL_ERROR` instead of losing or mismatching rows. Prebuilt keys are accepted only by a key getter with this base, and with one key per row of the block. Each slot insert builds the key of its first row again and compares it with the prebuilt key. The key getter throws when it reads a row that was not prepared. The scatter reads the prebuilt keys through the same `getKeyHolder` and `getBucketOfKey` as for the other maps, so a slot inserts only into its own buckets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `hashed` and `two_level_hashed` maps of a hash join store a row under `ColumnsHashing::hash128` of its key columns. `hash128` hashes one row at a time, with one virtual `updateHashWithValue` call per column. The new key getter `HashMethodHashedJoinKey` gives the same keys. Through `PreparedJoinKeys`, it builds the keys of many rows in one call of `sipHash128PaddedFixedStrings` or `sipHash128PaddedStrings`, and these functions hash 8 rows at a time. Each key getter has a `HashedJoinKey`. It chooses the layout of the hashed bytes from the key columns of the getter. The maps of an `OR` join have one map type, but each map has its own key columns. One fixed-width column is hashed where it is. Several fixed-width columns are copied into rows, 256 rows at a time. For a key with a `String` column, the bytes that `hash128` hashes are copied into a buffer laid out like the chars of a `ColumnString`. A chunk of this buffer ends after 256 rows or 64 KiB, and a longer row is hashed by itself. The layouts take number, `Decimal`, `FixedString` and `String` columns, and `Tuple`s of them. Any other key column, a build without NEON or AVX2, and a big-endian build use `hash128` for each row. A join loop skips the rows with a `NULL` key or a false `ON` condition. When a chunk of 256 rows has at least 32 such rows, the layouts copy and hash only the other rows of the chunk. The keys are those of `hash128`, so the getter needs no setting. They must be exactly equal. The build and the probe of one map can see different columns for one key, and so take different layouts: for example `Tuple(LowCardinality(String))` at the build and `Tuple(String)` at the probe. Debug and sanitizer builds check every key against `hash128`. With `parallel_hash`, the scatter of a right block to the slots builds the keys once with `buildAllKeys`, and the slots insert the rows with these keys. Before, the scatter hashed each right row, and its slot hashed it again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A null-safe join key `a <=> b` on nullable columns is wrapped as `tuple(a)`, unless all keys of the clause are fixed-width and fit in 32 bytes. The decorrelation of subqueries compares with `<=>` too. Such a `Tuple(Nullable(T))` key goes to the `hashed` map. There, `HashedJoinKey` hashed it with `hash128` for each row. `ColumnNullable::updateHashWithValue` hashes the null flag, and then the value only if it is not NULL. `HashedJoinKey` now copies these bytes into the buffer of its `String` layout. So a `Nullable` number, `Decimal`, `FixedString` or `String` is hashed many rows at a time, like the other key columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The join loops issue software prefetches only for a key getter with `has_cheap_key_calculation`. A prefetching loop reads the key of a row twice: once for the prefetch and once for the lookup. With `hash128` that hashed every row twice, so the `hashed` and `two_level_hashed` maps were never prefetched. `HashMethodHashedJoinKey` builds the keys ahead, and both reads take the same built key. So it now sets the flag, and a large `hashed` map is prefetched like the other maps. The prefetch leaves out the rows that the loop skips, so it does not make the getter hash their keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`05494_join_hashed_keys` joins on keys that take each layout of `HashedJoinKey`, and on keys that it hashes with `hash128` per row. It runs them with `hash`, `parallel_hash` with 1 and 8 threads, `grace_hash`, a spilling `parallel_hash` and `auto`. It covers every kind and strictness, `OR` joins with and without a condition in `ON`, joins that skip many rows for a `NULL` key or a condition in `ON`, and ASOF joins with a `Nullable` ASOF column. It also covers block sizes around the chunks of 256 rows, `joinGet`, and a `Join` table after `DETACH` and `ATTACH`. The keys are the same as before, so the reference was written by a build without the batched keys. `benchmark_hashed_join_key` compares `HashedJoinKey::buildRange` with `hash128` per row, for several key types. Co-Authored-By: Claude Opus 5.5 <[email protected]>
c4bada7 to
cb580d6
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the batched hashed-join key changes.
No open issues 🎉
What changed in this PR
This PR extends batched SipHash processing to the hashed and two_level_hashed join maps, improving joins on wide composite keys and mixed String keys while preserving existing key hashes.
Changes:
- Adds batched key construction using existing NEON and AVX2 hashing kernels, with per-row hashing for unsupported layouts and platforms.
- Reuses prepared keys for parallel-build routing, insertion, lookup, and prefetching, with skip-aware preparation.
- Adds stateless regression coverage and microbenchmarks for supported key layouts and join paths.
| File | Description |
|---|---|
tests/queries/0_stateless/05494_join_hashed_keys.sh |
Tests key types, join variants, skipped rows, chunk boundaries, and Join storage. |
tests/queries/0_stateless/05494_join_hashed_keys.reference |
Records expected counts and checksums. |
src/Interpreters/HashJoin/KeyGetter.h |
Adds prepared-key buffering and the hashed join key getter. |
src/Interpreters/HashJoin/HashJoinMethodsImpl.h |
Integrates prepared keys and skip-aware prefetching into join loops. |
src/Interpreters/HashJoin/HashJoinMethods.h |
Extends insertion interfaces to accept prebuilt keys. |
src/Interpreters/HashJoin/HashJoin.cpp |
Builds keys during parallel scatter and passes them to insertion. |
src/Interpreters/HashJoin/HashedJoinKey.cpp |
Implements layout selection, row packing, and batched hashing. |
src/Interpreters/HashJoin/benchmarks/CMakeLists.txt |
Registers the hashed-key microbenchmark. |
src/Interpreters/HashJoin/benchmarks/benchmark_hashed_join_key.cpp |
Compares whole-block, chunked, and per-row key construction. |
src/Interpreters/HashJoin/AddedColumns.h |
Declares a shared row-skip helper. |
src/Interpreters/HashJoin/AddedColumns.cpp |
Shares skip-mask construction between build and probe paths. |
src/Interpreters/CMakeLists.txt |
Includes the new benchmark directory. |
src/Common/HashTable/Prefetching.h |
Exposes maximum look-ahead for prepared-key retention. |
Review effort: Balanced
clang-tidy checks `cppcoreguidelines-pro-type-member-init` and `hicpp-member-init` reported that `Part` did not initialize `data`, `size` and `offsets`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129328&sha=cb580d635f3fb094f9b332ba30c2f6ef520b947a&name_0=PR&name_1=Build%20%28arm_tidy%2C%203%2F4%29 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`PreparedJoinKeys::buildAllKeys` built the key of every row of the block, even when the selector lists fewer rows. For example, `addBlockToJoin` takes the rows with a `NULL` `ASOF` key out of the selector. The scatter and the slot inserts never read the keys of those rows. `buildAllKeys` now takes the selector and builds the keys of the listed rows only. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A probe that reaches `max_joined_block_rows` hands the rest of the block to the next call. That call built its first chunk of 256 keys at once. When each key has many matches, a call uses only a few rows, so the other keys were built for nothing and built again by the next call. The first chunk of a call that starts after the first row of the block now has 8 rows, the group size of `SipHashStrings`. Each next chunk doubles, up to 256 rows. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`05494_join_hashed_keys` ran for more than 180 seconds in the `amd_tsan` and `amd_msan` flaky checks. It now runs every key with `hash` and `parallel_hash`. The other algorithms and the join kinds run with a few keys of different layouts. The queries on the table with 150000 rows moved to `05508_join_hashed_keys_prefetch`, so each test has its own time limit. The queries that stay give the same results as before. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129328&sha=829a170e6b4a020ee0f74ae7be83fd25fe74bc34&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The flaky check runs a copy of the changed test on every worker. In the `amd_binary`, `amd_debug`, `amd_tsan` and `amd_asan_ubsan` flaky checks, both tests then take about three minutes, and the check fails a test that takes more than 180 seconds. Alone, each test takes about three seconds. The targeted checks, which run one copy at a time, pass. The flaky check does not apply the 180 seconds limit to a test with the tag `long`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129328&sha=0d59c0ac264fa546cb080100d2da60eb9d6322eb&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20flaky%20check%29 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes37 object files changed (+1.64 MiB total), 1 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units820 translation units recompiled, 7264 s compile time in total, 819 of them have a recent master baseline. |
…rallel replicas A query with parallel replicas reads the right table to send it to the replicas, and a `Join` table with `hashed` keys cannot be read: its keys are not stored in the map. `master` fails the same way. The `ParallelReplicas` job of the `05494_join_hashed_keys` test reported this as `UNSUPPORTED_JOIN_KEYS`. Disable parallel replicas for that one query, as other tests of `Join` tables do. The rest of the test still runs with them. Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/129328/05d06e97a3d41986e3bf129bf06eba38400bd65a/pr/result_stateless_tests_arm_binary_parallelreplicas_s3_storage_parallel.json Related: ClickHouse#129328 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
m-selmi
left a comment
There was a problem hiding this comment.
Should we add an xml performance test? the google benchmark does not run in CI so it can't catch future regressions.
Added hashed_join_keys.xml. right_full_parallel_join already hits the hashed map (String + UInt64), and it shows 1.58x on amd and 1.62x on arm in this PR’s perf run. |
Each new case is one `String` column of about 16 MiB, with keys of 192 B up to 160 KiB. The longer the keys are, the fewer rows fit in a chunk of the key builder. Batched keys beat `hash128` per row up to keys of about 8 KiB. Above that, they trail it by up to 11 %. A key over 64 KiB is already hashed per row. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The `hashed` map holds keys of several columns that do not fit in 32 bytes, a `String` with other columns, and null-safe keys on `Nullable` columns. The test joins on each of them, on an `OR` of two of them, and on `String` keys of about 2 KiB and 12 KiB. The Google benchmark of `HashedJoinKey` does not run in CI, so it cannot catch a regression. Requested in ClickHouse#129328 (review) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…llel replicas
With `max_threads = 2` in the ParallelReplicas job, `joinGetOrNull('j_s_u64', ...)` failed with `UNKNOWN_TABLE`: `Table default.j_s_u64 does not exist`. The table is in the database of the test, so the queries that call `joinGet` now run without parallel replicas, as the join with the `Join` table already does.
Failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129328&sha=3319ba3a571cf6cce910532cc4d9b350991ce893&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
m-selmi
left a comment
There was a problem hiding this comment.
Nice optimization, thanks!
|
@harikrishnan94 Please check all the failures, not only timeouts: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129209&sha=013785db07d54a273f8795ffd2b6a00f4cb1345f&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 @groeneai Please verify. If it's not being fixed, let's consider reverting temporarily since this is affecting other PRs CI |
|
@groeneai The Please raise a PR: in |
The test (added by ClickHouse#129328) sweeps key shapes, join algorithms, join kinds, key widths and block sizes: about 190 joins of a 3,300-row table with a 3,200-row one. On master its six `Stateless tests (amd_msan, parallel, 3/3)` runs so far average 288.6 s (max 401.7 s, against the 600 s per-test timeout), while release takes 6.9 s, debug 5.0 s, asan_ubsan 41.8 s and tsan 87.6 s (p50). That is far over ClickHouse#115050's bar (mean OK duration above 60 s under MSan), which merged before this test existed. The cost is the sanitizer's, not a random setting: every query pins its join algorithm, and the duration follows the test's position in the job (127 s early in a job, 230-402 s late). ASan, UBSan, TSan, debug and release keep running it, and in every debug/sanitizer build `HashedJoinKey::buildRange` still asserts each batched key against the row-by-row one. MSan stress jobs ignore `no-msan`, and `05508_join_hashed_keys_prefetch` (mean 61.9 s) stays under MSan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…allel replicas With parallel replicas, an `INSERT ... SELECT` into a `Join` table runs on every replica, and the inserts share the initial query id. `StorageJoin` takes its write lock by that id, so when two replicas insert at the same time, the second one fails with `DEADLOCK_AVOIDED`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129209&sha=013785db07d54a273f8795ffd2b6a00f4cb1345f&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 Related: ClickHouse#129209 Related: ClickHouse#129328 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I checked CIDB. Every failure mode of
The other five rows in the report you linked are |
Master gained two key encoders that read a `Nullable` null-map byte as a value, and both must agree with the rest of this PR: - `HashedJoinKey::buildRows` (ClickHouse#129328) copies the bytes that `hash128` hashes, and its own contract is that every way of building a key gives exactly `hash128`. This PR makes `ColumnNullable::updateHashWithValue` hash `byte != 0`, so after the merge the copied raw byte broke that contract: on the merged tree `SELECT count() FROM t l JOIN t r ON l.s <=> r.s` over a Native null map with bytes 0, 1 and 2 aborts on the debug check in `buildRange` (AVX2 and NEON builds). It now copies `byte != 0`: 500 rows, where master gives 300. - `encodeFixedSizeKeys` (ClickHouse#124907) packs NULL into a one-bit field, so a byte 2 set the lowest bit of the column before it. With `transform_null_in = 1` and a set spilled to disk, `(0, NULL)` was found in `{(1, 0)}`: master 10 rows, 0 in memory. The right side is read back from the canonical in-memory keys, so only the probe side carried the raw byte. Both are bit-identical on 0/1 maps. 05210 covers both cases, and gains a `groupUniqArray(tuple(s))` case for the arena key encoder (`serializeValueIntoArena`), which no case reached: reverting it left 05210 green, now it gives 3 keys where 2 are correct. 05210 also pins `optimize_if_transform_const_strings_to_lowcardinality` to 0: the runner randomizes it since ClickHouse#80263, and with it `if` returns `LowCardinality(Nullable(String))`, which has no `.null` subcolumn, so the `if` case failed with UNKNOWN_IDENTIFIER on half the runs. 05211 is removed: ClickHouse#129812 made the Iceberg null count use `countBytesInFilter`, so that reader is master's now and the merge drops it from this PR (05211 passes on master). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The check of the tests a PR adds or changes (ClickHouse#129330) failed a PR only when a query's time grows run over run on the tested server. A test whose runs are noisy without a trend passed its own PR, and in master_head PR mode the report's own unstable/changed verdict never fails a PR. That is how system_clusters_replicated_databases (ClickHouse#122223) got in: tested-server spread (stddevPop / median of its runs) 0.41-2.1 in its PR, now > 0.5 on both master servers in about 99% of runs and the noisiest test on master. The check now also fails on an unstable query of such a test: - PR changes only files under tests/ and the reference is the performance reference build of the tested master commit's sources (find_prev_build's new third value; a reference of an older commit, as in about a quarter of PR jobs, does not count): both servers run the same code built the same way, so the report's verdict judges the test; fail on changed_fail or unstable_fail of report/all-queries.tsv. A query that failed on the reference server and ran only on the tested one is not in that file; it is judged by the rule below. - Any other PR or reference (code changes, the official-build fallback, or an older reference): the report measures the PR's change, not the test (the floors flag 79% of the heads of the 214 code PRs that changed a perf test in 2026-11-12..21, their own speedups). Fail when stddevPop / median of the tested server's runs is above 0.5 (at least 5 runs). A spread the change causes also fails: after the merge both master servers run that code. The bar 0.5 flags 0.5% of those code-PR heads and 0.2% of quiet tests' master heads (CIDB backtest), and all 4 jobs of ClickHouse#122223. A query the trend check already reports gets only its trend row. The reading loop of find_run_trends moves to read_query_runs, shared by both checks; run_trend_gate becomes changed_tests_gate. Validated locally on downloaded job logs (no test of the test infrastructure): ClickHouse#122223's 4 jobs fail (the old check passes them); the new tests of ClickHouse#129328, ClickHouse#124553, ClickHouse#131203 (code PRs) and the tests-only ClickHouse#130763, ClickHouse#129627 pass; the run-trend output is unchanged on all 1754 tests of 14 jobs. Related: ClickHouse#100759 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #129204
Related: #128972
A hash join keeps its right rows in the
hashedmap when its keys are, for example, several columns that do not fit in 32 bytes together, or aStringwith other columns. The map stores each row underhash128, the 128-bit SipHash of its key values.The key getter of these maps now builds the keys of many rows at once.
For a user:
hashedmap are faster. These are keys of several columns that do not fit in 32 bytes, aStringwith other columns,Tuplekeys, and null-safe<=>keys onNullablecolumns. The keys do not change, so the results do not change either.Decimal,FixedString,String, andTupleandNullableof these, keephash128per row. Examples areArray,Mapand aLowCardinalityinside aTuple.enable_software_prefetch_in_joinnow covers thehashedmaps too. The prefetch leaves out the rows that the join skips: those with aNULLkey or a falseONcondition.INsets, the runtime filters and the other join maps are unchanged.Sample joins,
clickhouse local, median of 5 runs, each in a new process:The keys:
5 x UInt64:l.k1 = r.k1 AND l.k2 = r.k2 AND l.k3 = r.k3 AND l.k4 = r.k4 AND l.k5 = r.k5Stringof 16-40 bytes andUInt64:l.s40 = r.s40 AND l.u = r.uStringof 0-15 bytes andUInt64:l.s15 = r.s15 AND l.u = r.uNullable(String):l.ns <=> r.nsORof 2) and 1), withjoin_algorithm = 'hash', the only algorithm that runs itINNER JOINon m8g.24xlarge (Graviton 4), master → this PR:INNER JOINon c6i.24xlarge (Xeon 8375C, AVX2):On Graviton 4,
LEFT ANY JOINtakes 0.38-0.49 of the master time at 1 and 16 threads, and 0.60-0.91 at 96 threads. With 100K right rows, the ratios are 0.59-0.83 at 1 thread and 0.79-1.06 at 96 threads. At 96 threads such a query takes 30-91 ms, and the master binary differs from a copy of itself by up to 14 %.Reading order:
HashMethodHashedJoinKeyandPreparedJoinKeysinKeyGetter.h->HashedJoinKey::buildRange->sipHash128PaddedFixedStringsandsipHash128PaddedStrings-> theprepareRowscalls ininsertSlotRowsandjoinRightColumns->buildAllKeysinscatterImpl->usePrebuiltKeys.The key getter:
hash128, in the same order. SipHash of a byte stream does not depend on how the stream is split intoupdatecalls, so a batched key equals the per-row key. The two kinds can meet in one map. That happens on the per-row fallback, and when the build and the probe pick different layouts for the same map. An example is aTuple(LowCardinality(String))key, which is stillLowCardinalityat the build butStringat the probe. Debug and sanitizer builds check every key againsthash128.ORjoin can have different key columns, so each disjunct gets its own. A key of one fixed-width column, such asTuple(UInt64), is hashed where it is, like aFixedStringcolumn. Several fixed-width columns are copied side by side into rows, 256 rows at a time, and hashed the same way.Stringor aNullablecolumn is copied into a buffer laid out like aStringcolumn. Each row gets the bytes thathash128hashes. For aStringthese are its size plus one, its chars and a zero byte. For aNullablethey are the null flag, then the value if it is not NULL. A chunk ends after 256 rows or 64 KiB, and a longer row is hashed by itself.Tuplecount as key columns of their own. ANullablecolumn is copied when its nested column is a number,Decimal,FixedStringorString. A null-safea <=> bonNullablecolumns reaches thehashedmap as such aTuple(Nullable(T)). The column types are checked by exact type: aColumnConstor aColumnUniquereports theisFixedAndContiguousof its nested column.prepareRowsbefore it creates its prefetcher. The getter then builds the keys chunk by chunk as the loop reads them, and keeps the last 32 keys of a chunk for the prefetch look-ahead. With or without prefetch, the loop passes the rows with aNULLkey or a falseONcondition as skipped, and the prefetch leaves them out. When at least one row in 8 of a chunk is skipped, the getter copies and hashes only the other rows.ASOFjoin with aNullableASOF column, gets its keys built from the first listed row to the last, with the other rows skipped. AnORjoin with a condition inONlooks up every map for every row it does not skip, so it prepares the keys of every map.parallel_hash,scatterImplbuilds the keys of the whole right block to route its rows to the slots. The slots insert the rows with these keys. Each slot builds the key of its first row again and compares it, and a mismatch throws aLOGICAL_ERROR.HashedJoinKey.cppand does not depend on the mapped type, so the many instances of the join loops share it.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Hash joins whose keys use the
hashedhash table, such as several columns that do not fit in 32 bytes or aStringwith other columns, are faster: they hash the keys of 8 rows at a time with NEON on aarch64 and AVX2 on x86, and they prefetch the hash table. The keys and the results do not change.Workflow [PR]
Sync PR [sync-upstream/pr/129328]
Version info
26.11.1.1919-master(included in26.11and later)