Repository navigation
Conversation
…without values Reading a sparse column of a wide part reads its offsets and then always called the nested deserialization of the values, even when the offsets say the range has none. The wide reader's getter then created the stream's read buffer (stat, open, a max_read_buffer_size buffer), positioned it and read nothing. A `SELECT *` point lookup on a wide table with many mostly-default columns paid one open and one buffer per such column; for a column with only defaults in the part its value files are empty and were still opened. - SerializationSparse: in a wide part, a range without values does not call the nested deserialization. A read from a new mark only positions the value streams there through `seek_stream_to_current_mark_callback`, so that a later continuous read of the same column finds them where reading zero values would have left them. Compact parts and other formats keep the old path. - MergeTreeReaderStream: a `seekToMarkAndColumn` on a stream whose buffer does not exist yet is recorded and performed at the first `getDataBuffer`, so a stream that is only positioned is never opened. `init` and `adjustRightMark` are unchanged, so a deferred seek still lands after the read bound is set; an eager seek clears a pending one. Measured on master 94af623 (release build, one wide part of 100,000 rows, 400 columns, 3/4 UInt32 and 1/4 String): a point lookup in a granule without values opens 402 files instead of 902 and allocates 0.5 MB of read buffers instead of 66 MB; query memory 74 MB -> 6.4 MB (1600 columns: 293 -> 29 MB). The number of bytes read is unchanged. The value files are still opened by prefetching (which positions every stream up front) and on every read of a range that has values, so only the useless opens go away. The test reads a range that starts in a granule without values and continues into one with values, and fails when either the positioning or the deferred seek is dropped. Closes ClickHouse#130330 (analysis and patch by @ snelheidai). The variant that creates no streams at all for an all-default column touches `MergeTreeReaderWide` and is left for a separate change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… without values The skip path for a sparse range without values positions the value streams through `seek_stream_to_current_mark_callback`, which seeked without the `adjustRightMark` that `getStream` does first. Readers are reused across the read tasks of one part, so a value stream that read values in an earlier task still had that task's read bound. On object storage `AsynchronousBoundedReadBuffer` clamps a seek past the bound to the bound, and the next read of the range decoded the values of an earlier granule (`remote_filesystem_read_method = 'threadpool'`) or failed with `ATTEMPT_TO_READ_AFTER_EOF` (`'read'`). It needs one-mark read tasks and `remote_filesystem_read_prefetch = 0`: with prefetching, every non-empty stream is bounded and positioned before each read. Now an open stream gets the current read bound before it is positioned, the order `getStream` uses. A stream that is not open yet keeps its deferred seek, which runs after `getStream` sets the bound. The test gets an S3 case: one-mark tasks read granules 0 to 3, skip a granule with values, and read a granule whose first rows have none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
State why the read bound is set before the seek in seek_stream_to_current_mark_callback instead of restating the code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (2 rounds): 1 blocker fixed, 3 findings declined with evidence
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261111-043400 |
|
Workflow [PR], commit [06af739] Summary: ✅
AI ReviewSummaryReviewed #130699 at Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units310 translation units recompiled, 4100 s compile time in total, 310 of them have a recent master baseline. |
CI finish ledger - c5ee730Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261111-103006 |
The test measures reading sparse columns of a wide MergeTree part, which Iceberg tables do not have. In the Iceberg performance comparison jobs its queries fail with `Params with size 1 is not supported` (Code: 36), so no query is measured on both servers and the report is not built. `<test iceberg="0">` keeps the test out of the Iceberg configuration; the skip list is not used because editing it runs the whole Iceberg suite. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #130330
Related: #130692
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading a sparse column of a wide part no longer opens its value files for granules that contain only default values.
SELECT *point lookups, top-N queries and scans of wide tables with many mostly-default columns are up to 20% faster and use less memory (a 1600-column point lookup: 29 MB instead of 293 MB). Closes #130330.Description
A read of a sparse column of a wide part always called the nested deserialization of the values, even when the offsets say the range has none (analysis and patch by @ snelheidai). The wide reader then opened the value file, allocated a read buffer, positioned it and read nothing, also for the empty value files of an all-default column.
In a wide part, a range without values now only positions the value streams at the new mark through
seek_stream_to_current_mark_callback(a continuous read leaves them where they are). An already open stream first gets the current read bound, as ingetStream, because on object storage a seek past the old bound is clamped to it.MergeTreeReaderStreamperforms a seek requested before its buffer exists at the firstgetDataBuffer, after the read bound is set, so a stream that is only positioned is never opened. Compact parts, other formats and ranges with values keep the current path, and a prefetch still opens the streams it prefetches. A bad mark now reportsARGUMENT_OUT_OF_BOUNDat the first read instead of at the seek.Measured on master
94af6233(release build, one wide part of 100,000 rows), a 400-column point lookup in a granule without values:FileOpen902 -> 402,IOBufferAllocBytes66 MB -> 0.5 MB, query memory 74 MB -> 6.4 MB, bytes read unchanged. The new performance test (1600 columns) withperf.py: point lookups -19%, top-10 -18%, full scans -22% and -11%, dense control -0.2%. 4218 deterministic query/table/setting combinations (local and S3 disks, read pools, prefetch, caches,mmap, PREWHERE, subcolumns, a mutation, a compact part) return the same results as master. The new stateless test fails without the positioning, without the deferred seek, and on S3 without the read bound update.Creating no streams for an all-default column is the separate #130692.
Workflow [PR]
Sync PR [sync-upstream/pr/130699]