Skip to content

Read only the rescoring candidates of vector column with one row per block - #131027

Open
shankar-iyer wants to merge 29 commits into
ClickHouse:masterfrom
shankar-iyer:basic-statistics-fixed-array-size
Open

shankar-iyer wants to merge 29 commits into
ClickHouse:masterfrom
shankar-iyer:basic-statistics-fixed-array-size

Conversation

@shankar-iyer

@shankar-iyer shankar-iyer commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

When only known rows of a part are needed, namely a) the second stage of lazy materialization (the rescore of the
quantized-codes search) and b) the candidates of a quantized vector similarity index with vector_search_with_rescoring, the new setting merge_tree_use_one_row_per_block_layout reads an Array(BFloat16 | Float32 | Float64 | Int8) column only for these rows, instead of whole granules.

The column declares the layout with the new column-level setting uncompressed_fixed_array_size, the number of
elements of every row:

CREATE TABLE tab
(
    id UInt64,
    vec Array(Float32) SETTINGS (uncompressed_fixed_array_size = 768)
)
ENGINE = MergeTree ORDER BY id;

The Wide writer then stores every row of the column as one compressed block without compression (NONE, or column has a single Quantized codec), whatever the block sizes of the table. Note this has overhead of 25 bytes per row or per vector, but that is acceptable because each vector could be 3072 bytes or 6144 bytes or even more. The writers of all part types reject rows of any another length, and the Wide writer checks after writing that every block holds exactly one row. A row is then located arithmetically. The reader seeks the usual stream to its block, takes the block as stored (readCompressedBlock), checks it and copies it into the column. Other rows get empty arrays, which the existing filter removes. NOTE : Disk and S3 reads keep their usual chunk sizes; the saving is in checksums, copies and deserialization.

The setting can be specified only in CREATE TABLE, so every part of the table is written with it:

  • ALTER cannot add, change or remove it, change the type, the codec or the TTL of the column, or clear the column. The column cannot have a TTL.
  • The operations that bring in parts the table did not write are not supported for such a table yet: ATTACH PART
    and ATTACH PARTITION from the detached directory, ATTACH, REPLACE and MOVE PARTITION between tables, RESTORE of data, and ATTACH TABLE with a definition. They can be added in a follow-up.
  • Lightweight updates check the updated values against the setting, as the metadata of a patch part has no column
    settings.

Rows are read this way only if no column of the table has a default expression with an identifier: a column that a
part does not have is filled from its default before the filter, and such an expression could use the values of the
rows that are not read. Defaults such as now() are fine. The setting has no effect with the uncompressed cache or the columns cache.

On 200k rows × 768 Float32, a rerank of 100 candidates: 99 ms → 49 ms, 498 MiB → 150 MiB checksummed. The
remaining 150 MiB is the scan of the codes in the first stage.

Of the 1804 added lines, 725 are tests and 1079 are source code:

$ git diff master --numstat | grep -v contrib
1	0	src/Common/ProfileEvents.cpp
15	0	src/Compression/CompressedReadBufferBase.cpp
21	0	src/Compression/CompressedReadBufferBase.h
5	0	src/Compression/CompressedWriteBuffer.cpp
12	0	src/Compression/CompressedWriteBuffer.h
14	0	src/Core/Settings.cpp
9	1	src/Interpreters/InterpreterCreateQuery.cpp
62	0	src/Storages/AlterCommands.cpp
6	0	src/Storages/MergeTree/IMergeTreeReader.h
50	0	src/Storages/MergeTree/MergeTreeData.cpp
3	0	src/Storages/MergeTree/MergeTreeDataPartWriterCompact.cpp
64	2	src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp
17	0	src/Storages/MergeTree/MergeTreeDataPartWriterWide.h
2	0	src/Storages/MergeTree/MergeTreeIOSettings.cpp
3	0	src/Storages/MergeTree/MergeTreeIOSettings.h
254	0	src/Storages/MergeTree/MergeTreeOneRowPerBlockLayout.cpp
88	0	src/Storages/MergeTree/MergeTreeOneRowPerBlockLayout.h
155	0	src/Storages/MergeTree/MergeTreeOneRowPerBlockReader.cpp
48	0	src/Storages/MergeTree/MergeTreeOneRowPerBlockReader.h
34	0	src/Storages/MergeTree/MergeTreeReadTask.cpp
5	0	src/Storages/MergeTree/MergeTreeReadTask.h
14	0	src/Storages/MergeTree/MergeTreeReaderStream.cpp
6	0	src/Storages/MergeTree/MergeTreeReaderStream.h
139	1	src/Storages/MergeTree/MergeTreeReaderWide.cpp
16	0	src/Storages/MergeTree/MergeTreeReaderWide.h
30	1	src/Storages/MergeTree/MergeTreeSettings.cpp
3	1	src/Storages/StorageMergeTree.cpp
3	0	src/Storages/StorageReplicatedMergeTree.cpp
128	0	tests/queries/0_stateless/02354_vector_search_one_row_per_block.reference
300	0	tests/queries/0_stateless/02354_vector_search_one_row_per_block.sql
98	0	tests/queries/0_stateless/02354_vector_search_one_row_per_block_hnsw.reference
136	0	tests/queries/0_stateless/02354_vector_search_one_row_per_block_hnsw.sql
11	0	tests/queries/0_stateless/02354_vector_search_uncompressed_fixed_array_size_imports.reference
52	0	tests/queries/0_stateless/02354_vector_search_uncompressed_fixed_array_size_imports.sh

Changelog category (leave one):

  • Performance Improvement

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

Added the column-level setting uncompressed_fixed_array_size and the query setting merge_tree_use_one_row_per_block_layout. A vector column declared with uncompressed_fixed_array_size stores every vector as one uncompressed block, so that rescoring in vector search reads the full-precision vectors only for the candidate rows instead of whole granules.

🤖 Generated with Claude Code


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

shankar-iyer and others added 6 commits November 12, 2026 06:01
When a query reads known rows of a part - the second stage of lazy
materialization, or the candidates of a vector similarity index with
`vector_search_with_rescoring` - the new setting
`merge_tree_use_one_row_per_block_layout` reads an `Array(BFloat16)`,
`Array(Float32)`, `Array(Float64)` or `Array(Int8)` column only for these
rows, instead of whole granules.

This needs one row per block, stored without compression: `CODEC(NONE)` or
`CODEC(Quantized(...))`, and the column-level settings
`min_compress_block_size` and `max_compress_block_size` both equal to the
size of a row. `tryGetOneRowPerBlockLayout` checks the settings and the file
sizes, and `checkOneRowPerBlockArraySizes` checks once per part, on first use,
that every row has the same number of elements. The result is kept in
`IMergeTreeDataPart::hasOneRowPerBlockArraySizes`.

`MergeTreeReadTask` passes the selected rows to the main reader with the new
hook `IMergeTreeReader::setSelectedRows`. `MergeTreeReaderWide` then reads the
qualifying columns with `MergeTreeOneRowPerBlockReader`: it seeks the usual
stream to the block of each selected row, takes the block as stored with
`readCompressedBlock`, and copies the row into the column. The other rows get
empty arrays, which the filter that keeps the selected rows removes. Marks
and array sizes of the column are not read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The column-level `max_compress_block_size` of a `Quantized` column is set to
the size of one vector for one row per block. The writer applied it to every
stream of the column, so the array sizes and the quantized codes were also
stored in blocks of that size: the codes of a 768-dimensional `int8` column
in blocks of about 4 rows. Scanning the codes in the first stage of the
quantized search then processed 66671 blocks instead of 175 for 200000 rows.

Now it applies only to the stream of the array elements, as in
ClickHouse#111180, and the other streams
get the default. The scan of the codes takes 11-12 ms instead of 15-16 ms,
and the whole rerank query 46-47 ms instead of 49-50 ms.

Related: ClickHouse#111180

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A column that is missing from the part and has a default expression is
computed before the filter that keeps the selected rows, so the expression
saw the empty arrays of the other rows: with
`DEFAULT intDiv(64, length(vec))`, rescoring with
`merge_tree_use_one_row_per_block_layout` threw `ILLEGAL_DIVISION`. The
selected rows are not passed to the reader of such a part now.

A part written with other block sizes than the column has now can pass the
checks of the layout, and then fails to read with an error about the codec
or the checksum. Nothing before the read can tell it from a corrupted part,
so the exception now explains both causes and how to resolve the second:
merge the part or disable the setting.

Both cases are covered by the tests, found by the local codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ow reads

A column dropped by a pending mutation and added again is still in the
part, but it is computed from its default expression before the filter that
keeps the selected rows, like a missing column. The guard checked only
missing columns, so such a default expression saw the placeholder arrays.
It now covers every column that is not read from the part: missing, partly
missing, or skipped by a pending mutation.

A codec that compresses can produce blocks of exactly the size of a row, and
then the file has the sizes of one uncompressed block per row and passed the
checks of the layout. The declared codec of the column is now checked first:
every codec of it must be `NONE` or `Quantized`.

Both cases were found by the local codex review and are covered by the tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…column

A default expression can be evaluated before the filter that keeps the
selected rows, for a column that is not read from the part. Earlier fixes
checked the reasons for that one by one - a missing column, a column dropped
and added again by a pending mutation - and missed others, such as a pending
rename, where the column in the part has its old name.

Now the reads of only the selected rows are disabled when the default
expression of a requested column uses a column that gets placeholder values,
directly or through the default expressions of other columns, whatever the
reason the default would be evaluated. Defaults that do not use the vector
column, such as `DEFAULT now()`, keep the optimization. The check runs before
the one-time scan of the array sizes, so such a part is not scanned.

Also make the test of the block sizes of the quantized codes independent of
the randomized `index_granularity`: it counts the blocks decompressed, which
grows when the read is split into tasks that start at different marks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The usual read path calls `adjustRightMark` whenever it takes a stream, to
move the read boundary to the end of the current task. The reads of only the
selected rows took the stream without it, so a reader reused for another
task, as `MergeTreePrefetchedReadPool` does when the number of prefetches is
limited, kept the boundary of the previous task and failed with
`CANNOT_READ_ALL_DATA` past it. Found by the local codex review, and covered
by a test that fails without the fix.

Also remove the claim that the marks of the column are not read: the streams
load them, and the boundary above uses them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0c38b47]

Summary: ✅


AI Review

Summary

The PR adds an explicitly declared fixed-length array layout and an experimental selective reader for lazy materialization and vector rescoring. The writer enforces the row lengths and block geometry; metadata changes and unsupported part imports are rejected. Reviewed head: 0c38b4744a6ea3109703c307e8900047c74615a0. No remaining blockers or majors; the earlier inline findings are addressed in the current code. The description provides before/after performance measurements.

The consumer pass covered MergeTreeReaderIndex filtering for lazy materialization, the vector candidate filter, default evaluation, type conversions, shared array offsets, array subcolumns, projections, and reader reuse. Defaults with identifiers, mutation steps, patch readers, and both data caches disable selective reads; renames are excluded and type changes to declared columns are rejected. A local probe using the PR-head Fast test binary returned matching on/off results for all four supported element types, shared Nested offsets, and array subcolumns, and also exercised a projection. MergeTreeOneRowPerBlockReadRows = 15 confirmed selective reads occurred.

Missing context / blind spots
  • ⚠️ The current Fast test passed 02354_vector_search_one_row_per_block but skipped the HNSW and backup/restore regression tests by their tags. Those paths and replicated metadata were traced in source; normal CI must execute the excluded tests. No local replicated or remote-storage environment was used.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Nov 12, 2026
@shankar-iyer shankar-iyer changed the title Read only the rescoring candidates of vector columns with one row per block Read only the rescoring candidates of vector column with one row per block Nov 12, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-vector-index Vector similarity index in MergeTree: ANN/HNSW index build/query, usearch integration, vector ind... label Nov 12, 2026
…rows

During a pending `MODIFY COLUMN`, the type of a column in the part differs
from the requested type, and the reader converts the column before the
filter that keeps the selected rows. The conversion then ran on the
placeholder arrays of the other rows: for an `Array(Float32)` column being
converted to `QBit(Float32, 64)`, an HNSW rescoring query failed with
`Array arguments must have size 64 for QBit conversion, got 0`. Such columns
are read as usual now.

Found by the AI review of ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shankar-iyer and others added 5 commits November 15, 2026 01:05
During a pending rename, the column in the part has its old name. The checks
of the layout and of the default expressions then used that name, which can
belong to another column: after `RENAME COLUMN payload TO renamed_payload`
and `ADD COLUMN payload ...` in one `ALTER`, a default expression using
`renamed_payload` was not found, and it was evaluated on the placeholder
arrays, failing with `ILLEGAL_DIVISION`. A column with another name in the
part than requested is now read as usual, like one with another type.

The case of the reused reader in the test printed the ids returned by the
approximate vector index, which differ between runs. It now only checks that
the query does not fail, and still fails without the fix it covers.

Found by the AI review of ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A member of `Nested`, such as `n.d`, is requested as a subcolumn of `n`,
but its default expression is registered under `n.d`. The check of the
default expressions looked it up only by the name in storage, `n`, so a
default of a `Nested` member using the vector column was evaluated on the
placeholder arrays. The default is now looked up under both names.

Found by the local codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The check of the default expressions mapped the requested columns to the
columns whose defaults could be evaluated, and missed some of them, such as
`n.d` when `n.d.x` of a `Nested` member is requested: each way of naming a
column was another case. Now the reads of only the selected rows are
disabled when any default expression of the table uses a column that gets
placeholder values. Chains of defaults need no longer be followed, as the last
default of a chain uses such a column directly. A table with a default
expression derived from the vector column does not get the optimization.

Found by the local codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed-row reads

A default expression can name the vector column with a qualifier, such as
`dummy.vec`, which is resolved to `vec` when the default is evaluated. The
check compared whole identifiers with the names of the columns that get
placeholder values, and missed it. Now any part of an identifier is
compared, which covers qualified names and subcolumns alike.

Found by the local codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reads of only the selected rows give placeholder values to the other rows
before the filter that removes them, which is a new way of reading, so the
setting is experimental, and `allow_feature_tier` can forbid it.

Found by the local codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shankar-iyer and others added 2 commits November 15, 2026 03:22
…rom its default

Instead of looking for the vector columns in the default expressions, which missed names such as `dummy.a.b` for a
column `a.b`, the selected-row reads are disabled when any requested column of the table is absent from the part,
partially read, dropped by a pending mutation, or marked missing in the part. Only then is a default evaluated before
the filter that keeps the selected rows. Virtual columns such as `_part_offset` are not filled from defaults.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0c38b4744 with master 8930b7fa5 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

124 object files changed (+395.95 KiB total), 2 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeOneRowPerBlockLayout.cpp.o new 141.80 KiB +141.80 KiB
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeOneRowPerBlockReader.cpp.o new 79.20 KiB +79.20 KiB
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeReaderWide.cpp.o 463.85 KiB 519.75 KiB +55.90 KiB (+12.05%)
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp.o 404.39 KiB 445.46 KiB +41.07 KiB (+10.16%)
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeData.cpp.o 4.73 MiB 4.75 MiB +26.39 KiB (+0.55%)
src/CMakeFiles/dbms.dir/Storages/AlterCommands.cpp.o 901.10 KiB 927.20 KiB +26.09 KiB (+2.90%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

684 translation units recompiled, 4855 s compile time in total, 682 of them have a recent master baseline.

Translation units without a recent master baseline:

  • src/Storages/MergeTree/MergeTreeOneRowPerBlockLayout.cpp: 5.6 s

Job report

shankar-iyer and others added 6 commits November 15, 2026 09:10
The layout was inferred from the column-level settings when a part was read, with checks of the totals of the file
sizes and, once per part, of the array sizes. The settings describe the parts written from now on, so a part written
before `ALTER TABLE ... MODIFY COLUMN ... SETTINGS`, or with an adaptive write buffer, can have other blocks whose
sizes add up to the same totals. A computed position then lands in the middle of another row, which was read without
an error.

Now the writer of a Wide part checks what it wrote to the file of the array elements of a column: one block per row,
every block of one row stored without compression (`CompressedWriteBuffer::getBlockStatistics`), and every row of the
same number of elements. Only then it writes a marker file, `<stream>.<hash of the file>.one_row_per_block`, which is
in the checksums of the part. The reader checks the marker against its checksum, built from the column settings and
the checksum of the file of the elements, so it reads nothing from disk and keeps no state in the part. Parts without
a matching marker are read as usual. The name contains the hash of the file it describes, so a mutation that rewrites
the column writes a marker of another name instead of writing into one hardlinked from the source part.

This removes the per-part cache of the array-size check from `IMergeTreeDataPart` (64 bytes per part, which failed
the storage memory check `07_many_parts.sql`), and the error of the hand-crafted part in `05617` on S3 and Azure,
where the read now gives the same result with the setting on and off. `05617` gets on/off regressions for a part
written with an adaptive write buffer, a merged part and mutated parts.

`05618` failed in the flaky check because it ran longer than 180 s: the thread fuzzer of that job migrates the thread
on every mutex lock and unlock, which makes building HNSW indexes very slow. The tables are now smaller (500 rows
instead of 2000, 4000 instead of 20000); with the same thread fuzzer environment locally, 8 concurrent runs take
50-58 s instead of 170-193 s.

Related: ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-length name

Found by a local review:

- The marker was bound only to the file of the array elements. A mutation that changes the sizes of the arrays but
  not the bytes of the elements, e.g. rows of 64 ones that become rows of 63 and 65 ones, keeps that file as it is,
  and the marker hardlinked from the source part still matched, so rows were read across the blocks: `length` and
  `arraySum` gave 64 instead of 63 and 65 with the setting on. The marker now also holds the size and the hash of the
  file of the array sizes, which defines where the rows begin, and is used only if both match.
- The name of the marker was the name of the stream with 51 bytes appended, which exceeds the limit of the file
  system for long column names kept as is with a large `max_file_name_length`, and the insert failed with
  `File name too long`, even with the setting off. The name is now a hash of the name of the stream and of both
  checksums, `<hash>.one_row_per_block`, of the same length for every column.

`05617` gets regressions for both cases.

Related: ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mutation

Found by a local review: a mutation that hardlinks the files it does not rewrite also hardlinked the markers of the
files it rewrote, together with their checksums. Each rewrite of a vector column added a marker, so the checksums of a
part depended on the history of mutations: two separate updates left three markers, the same updates as one mutation
left two, with identical files of data. Replicas that execute mutations in other batches would get different
checksums for the same part.

At the end of such a mutation, the markers that are not named after the current files of array elements and array
sizes of the part are removed from the checksums and from the part (`getStaleOneRowPerBlockMarkers`), so the markers
of a part depend only on its files. `05617` checks that separate and combined mutations give the same
`hash_of_all_files`.

Related: ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…essed_fixed_array_size`

Replace the write-time marker files with a column-level MergeTree setting that can be
specified only in `CREATE TABLE`. It declares the number of elements of every row of an
`Array(Float32/Float64/BFloat16/Int8)` column and makes the Wide writer store every row as
one uncompressed block, so every part of the table has the layout.

- `CREATE` validates the type, the codec (`NONE` or `Quantized`), no TTL, and no
  `min_compress_block_size`/`max_compress_block_size` alongside.
- `ALTER` cannot add, change or remove the setting, change the type, the codec or the TTL of
  such a column, make it `ALIAS`/`EPHEMERAL`, or clear it.
- `ATTACH PART`/`PARTITION` from the detached directory is not supported for such tables;
  `ATTACH`/`REPLACE PARTITION FROM` requires the same setting in both tables.
- The Compact and Wide writers reject rows of another length; the Wide writer asserts one
  block per row after writing.
- The reader trusts the table definition and throws `CORRUPTED_DATA` if the file sizes of a
  part contradict it.
- Selected rows are read only if no column has a default expression with an identifier,
  instead of checking the state of every part.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mpressed_fixed_array_size`

- `RESTORE` with `allow_different_table_def` is not supported for a table with a column with
  the setting. Without it, the definition in the backup must be the same.
- Lightweight updates check the updated values against the metadata of the table, as the
  metadata of a patch part has no column settings.
- `ATTACH` from the detached directory is rejected in `attachPartition` instead of
  `tryLoadPartsToAttach`, so that the recovery of a replica after the loss of its metadata in
  Keeper can attach its own parts again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pressed_fixed_array_size`

Every operation that brings in parts that the table did not write throws `NOT_IMPLEMENTED`
for such a table: `ATTACH PART` and `ATTACH PARTITION` from the detached directory,
`ATTACH`, `REPLACE` and `MOVE PARTITION` between tables (also with the same setting),
`RESTORE` of data, and `ATTACH TABLE` with a definition. The parts would be read at positions
computed from the setting. Support can be added later. The recovery of a replica, which
attaches its own parts, is not affected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shankar-iyer and others added 3 commits November 15, 2026 16:51
…array_size`

- `RESTORE` of data is rejected in `restorePartsFromBackup`, which the restore of
  `StorageReplicatedMergeTree` also calls; it overrides `restoreDataFromBackup`.
- `ATTACH TABLE` with a definition is rejected also when the columns are copied from another
  table with `AS`.
- The codec of such a column must be a single `NONE` or `Quantized` codec: a chain of codecs
  adds a header to every block, even `CODEC(NONE, NONE)`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The formatter writes `ATTACH TABLE t UUID '...' ENGINE = ... AS template` as
`ATTACH TABLE t UUID '...' AS template ENGINE = ...`, which the parser reads as
`AS [NOT] REPLICATED`, so debug builds failed with `Inconsistent AST formatting`.
The test uses `ATTACH TABLE ... FROM '<path>' ... AS template` instead.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131027&sha=83e52e0c209c23c0918f7ab4eadcc5bcf4148637&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. and removed comp-vector-index Vector similarity index in MergeTree: ANN/HNSW index build/query, usearch integration, vector ind... labels Nov 16, 2026
@shankar-iyer

Copy link
Copy Markdown
Member Author

Perf Improvement With this PR

Vector Stress Test on latest master
Screenshot 2026-11-16 at 12 03 06 PM

Vector Stress Test with this PR
Screenshot 2026-11-16 at 12 03 59 PM

Check the latency improvements in rabitq and turboquant runs

… private `master`

Moves the include of `MergeTreeOneRowPerBlockLayout.h` in `InterpreterCreateQuery.cpp` and the declaration of
`setSelectedRows` in `IMergeTreeReader.h`, away from lines changed in `master` and in the private `master`. Nothing else
changes.

Related: ClickHouse#131027
Related: ClickHouse/clickhouse-private#87499

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 16, 2026

@clickhouse-gh clickhouse-gh Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review approves this commit, see the AI Review comment.

@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 16, 2026 09:28

AI review of a later commit does not approve the PR, see the AI Review comment.

@rschu1ze rschu1ze self-assigned this Nov 18, 2026
Resolves a conflict with ClickHouse#131027 writer code after
ClickHouse#130784, which changed how `MergeTreeDataPartWriterWide` finds the streams of
a column. `addStreams` now registers the streams of every column once, in `resolved_streams_by_column`, and the functions
called for every granule, `getCurrentMarksForColumn` and `writeColumn`, iterate that list instead of calling
`enumerateStreams` and building the stream names again.

- `writeColumn`: both sides added a line at the same place, the count of the rows of a column with the setting
  `uncompressed_fixed_array_size` and the lookup of the resolved streams. Both are kept.
- `getCurrentMarksForColumn`: the check that flushes the buffer of the elements of such a column after every row used the
  `substream_path` of the callback of `enumerateStreams`, which the loop over the resolved streams does not have. The
  merge had no textual conflict there, but did not compile. The stream of the elements is now recognized by its name,
  which `addStreams` records in `FixedArrayColumn::stream_name` and is the `escaped_column_name` of the stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 19, 2026
shankar-iyer and others added 2 commits November 20, 2026 15:24
`master` is now 26.12, and the style check requires the settings added by this PR, `merge_tree_use_one_row_per_block_layout`
and `uncompressed_fixed_array_size`, to be recorded in the history under the current version.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131027&sha=39325ac952b30957e122db167470622d07dd36ce&name_0=PR&name_1=Style%20check
ClickHouse#131027

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@shankar-iyer

Copy link
Copy Markdown
Member Author

@rschu1ze Refreshed to latest master to clear CI failures, this run should be green. Please continue review.

@stresshouse

stresshouse Bot commented Nov 20, 2026

Copy link
Copy Markdown

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — inconclusive across 29 queries analysed

PR verdict: not_sure. 3 measured difference(s) not attributable to this PR. clickbench Q10: The measured difference cannot be attributed to this PR from the available source evidence. Tested merge 45d16045 (first parent 3757c4d9, PR head 0c38b47) adds the uncompressed_fixed_array_size / merge_tree_use_one_row_per_block_layout feature. On the read side, MergeTreeReaderWide::readRows takes the new branch only when one_row_per_block_readers is non-empty. setSelectedRows fills that list only when the setting is enabled (default false) and a column has the uncompressed_fixed_array_size setting, which applies only to Array(Float*/Int8) columns. Q10 reads MobilePhoneModel and UserID from … clickbench Q30: The measured difference cannot be attributed to this PR from the available source evidence. In tested merge 45d16045 the new MergeTreeReaderWide::readOneRowPerBlock branch runs only when setSelectedRows found an eligible column. That needs merge_tree_use_one_row_per_block_layout=1 (default false) and an Array column with uncompressed_fixed_array_size. Q30 reads only scalar hits columns (SearchPhrase, SearchEngineID, ClientIP, IsRefresh, ResolutionWidth), so it uses the existing read path, and its time goes to hash aggregation that this PR does not change. The query history is noisy, and the … clickbench Q31: The measured difference cannot be attributed to this PR from the available source evidence. Tested merge 45d16045 gates the new read path in MergeTreeReaderWide (setSelectedRows/readOneRowPerBlock) on settings.use_one_row_per_block_layout, which defaults to false, and on Array columns carrying uncompressed_fixed_array_size. Q31 reads only scalar hits columns and is dominated by building a large aggregation hash table. The PR's other runtime changes are on the write side: CompressedWriteBuffer block statistics and the checkUncompressedFixedArraySizes calls in the part writers. A SELECT …

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 10 not_sure 94 109 +16.0% <0.0001 aggregation: The measured difference cannot be attributed to this PR from the available source evidence. Tested merge 45d16045 (first parent 3757c4d9, PR head 0c38b47) adds the uncompressed_fixed_array_size / merge_tree_use_one_row_per_block_layout feature. On the read side, MergeTreeReaderWide::readRows takes the new branch only when one_row_per_block_readers is non-empty. setSelectedRows fills that list only when the setting is enabled (default false) and a column has the uncompressed_fixed_array_size setting, which applies only to Array(Float*/Int8) columns. Q10 reads MobilePhoneModel and UserID from …
⚠️ 30 not_sure 159 192 +21.1% <0.0001 aggregation: The measured difference cannot be attributed to this PR from the available source evidence. In tested merge 45d16045 the new MergeTreeReaderWide::readOneRowPerBlock branch runs only when setSelectedRows found an eligible column. That needs merge_tree_use_one_row_per_block_layout=1 (default false) and an Array column with uncompressed_fixed_array_size. Q30 reads only scalar hits columns (SearchPhrase, SearchEngineID, ClientIP, IsRefresh, ResolutionWidth), so it uses the existing read path, and its time goes to hash aggregation that this PR does not change. The query history is noisy, and the …
⚠️ 31 not_sure 216 242 +12.3% <0.0001 aggregation: The measured difference cannot be attributed to this PR from the available source evidence. Tested merge 45d16045 gates the new read path in MergeTreeReaderWide (setSelectedRows/readOneRowPerBlock) on settings.use_one_row_per_block_layout, which defaults to false, and on Array columns carrying uncompressed_fixed_array_size. Q31 reads only scalar hits columns and is dominated by building a large aggregation hash table. The PR's other runtime changes are on the write side: CompressedWriteBuffer block statistics and the checkUncompressedFixedArraySizes calls in the part writers. A SELECT …

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.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 1a2261df-f32b-4799-b8cb-4170728507dc
  • MIRAI run: 2fef682b-bdb0-4f0c-af70-481b29a0c012
  • PR check IDs:
    • clickbench_502410_1795193562
    • clickbench_502416_1795193562
    • tpch_adapted_1_official_502423_1795193562
    • tpch_adapted_1_official_502446_1795193562

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-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants