Skip to content

Read columns of Compact part in the order of the file (to avoid backward seeks) - #131439

Merged
yakov-olkhovskiy merged 3 commits into
ClickHouse:masterfrom
azat:master
Nov 20, 2026
Merged

yakov-olkhovskiy merged 3 commits into
ClickHouse:masterfrom
azat:master

Conversation

@azat

@azat azat commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

MergeTreeReaderCompactSingleBuffer reads all columns of a granule with one buffer, in the order of columns_to_read. Mutation passes them in the order of NameSet, so the reader seeks backward, and each backward seek out of the buffer is a new request that reads the data after it again, which drastically increases amount of IO/S3 requests and amount of read data.

Changelog category (leave one):

  • Performance Improvement

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

Read columns of Compact part in the order of the file (to avoid backward seeks)

Introduced in: #98884
Fixes: https://github.com/ClickHouse/clickhouse-private/issues/87943


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

Version info

  • Merged into: 26.12.1.40-master (included in 26.12 and later)
  • Backported to: 26.11.1.2919, 26.10.12.13, 26.9.38.9, 26.8.46.6

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [54374de]

Summary: ✅


AI Review

Summary

The PR reads full columns of Compact parts in physical file order to reduce backward seeks and repeated S3 reads during mutations. No actionable findings remain after reviewing the current diff, surrounding reader and cache logic, and all prior discussion. The added S3 I/O regression test passed 50 repeated ASan/UBSan runs before the final master merge. No local builds or tests were run.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Nov 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 54374debe with master e627fea5e (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.

Compile time of recompiled translation units

8 translation units recompiled, 15 s compile time in total, 8 of them have a recent master baseline.

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Nov 13, 2026
@yakov-olkhovskiy yakov-olkhovskiy self-assigned this Nov 14, 2026
…ard seeks)

`MergeTreeReaderCompactSingleBuffer` reads all columns of a granule with
one buffer, in the order of `columns_to_read`. Mutation passes them in
the order of `NameSet`, so the reader seeks backward, and each backward
seek out of the buffer is a new request that reads the data after it
again, which drastically increases amount of IO/S3 requests and amount of
read data.

Co-Authored-By: Claude Fable 5.2 <[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 20, 2026
@stresshouse

stresshouse Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 28 queries analysed

no significant changes detected. K_source=4 K_base=10 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: a082d647-ebd7-455d-98e3-9e0ba8d6c250
  • MIRAI run: 23f69212-6ddb-4970-90e8-9a438f9e0439
  • PR check IDs:
    • clickbench_467553_1795176309
    • clickbench_467746_1795176380
    • tpch_adapted_1_official_467945_1795176532
    • tpch_adapted_1_official_468063_1795176538

@yakov-olkhovskiy
yakov-olkhovskiy added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ClickHouse:master with commit 3addbf9 Nov 20, 2026
195 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 20, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
@azat
azat deleted the master branch November 20, 2026 12:24
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #131439 to 26.11: Read columns of Compact part in the order of the file (to avoid backward seeks)
robot-ch-test-poll2 added a commit that referenced this pull request Nov 24, 2026
Cherry pick #131439 to 26.8: Read columns of Compact part in the order of the file (to avoid backward seeks)
robot-clickhouse added a commit that referenced this pull request Nov 24, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Nov 24, 2026
Cherry pick #131439 to 26.9: Read columns of Compact part in the order of the file (to avoid backward seeks)
robot-clickhouse added a commit that referenced this pull request Nov 24, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Nov 24, 2026
Cherry pick #131439 to 26.10: Read columns of Compact part in the order of the file (to avoid backward seeks)
robot-clickhouse added a commit that referenced this pull request Nov 24, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 24, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 24, 2026
Backport #131439 to 26.9: Read columns of Compact part in the order of the file (to avoid backward seeks)
clickhouse-gh Bot added a commit that referenced this pull request Nov 24, 2026
Backport #131439 to 26.8: Read columns of Compact part in the order of the file (to avoid backward seeks)
clickhouse-gh Bot added a commit that referenced this pull request Nov 24, 2026
Backport #131439 to 26.10: Read columns of Compact part in the order of the file (to avoid backward seeks)
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-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants