Skip to content

Allow vertical merge with TTL - #97332

Merged
CurtizJ merged 7 commits into
ClickHouse:masterfrom
murphy-4o:murphy_issue_85338
Mar 3, 2026
Merged

CurtizJ merged 7 commits into
ClickHouse:masterfrom
murphy-4o:murphy_issue_85338

Conversation

@murphy-4o

@murphy-4o murphy-4o commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Fixes: #85338

Tables with DELETE TTL rules can now use the more memory-efficient vertical merge algorithm instead of being forced into horizontal merge. This significantly reduces peak memory usage during merges on wide tables with many columns. Controlled by the new vertical_merge_optimize_ttl_delete MergeTree setting (enabled by default).

Changelog category (leave one):

  • Improvement

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

Tables with DELETE TTL rules can now use the vertical merge algorithm.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.3.1.297

@CLAassistant

CLAassistant commented Feb 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@clickhouse-gh

clickhouse-gh Bot commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [302aabd]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Feb 19, 2026
@CurtizJ CurtizJ self-assigned this Feb 24, 2026
@murphy-4o
murphy-4o requested a review from CurtizJ February 25, 2026 11:08

@CurtizJ CurtizJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good in general. I've left a few comments.

Comment thread src/Storages/MergeTree/MergeTask.cpp Resolved
Comment thread src/Storages/MergeTree/MergeTask.cpp Resolved
Comment thread src/Storages/MergeTree/MergeTask.cpp Resolved
This commit introduces the TTLDeleteFilterTransform class, which evaluates TTL delete expressions and produces a filter column for vertical merges. It optimizes the handling of expired rows by integrating TTL logic directly into the merging process. Additionally, a new setting, vertical_merge_optimize_ttl_delete, is added to control this behavior. The changes also include updates to the MergeTask to incorporate the new transform and related tests to validate its functionality.

Signed-off-by: murphy-4o <>
Signed-off-by: murphy-4o <[email protected]>
- Remove unused `is_table_ttl` field from TTLDeleteFilterTransform
- Track new_ttl_info per delete TTL entry and finalize into data part,
  matching ITTLAlgorithm::finalize behavior
- Extract common TTL conditions into canVerticalTTLDelete() to unify
  duplicated logic between chooseMergeAlgorithm and isVerticalTTLDelete
- Remove force_ttl restriction since the filter transform already
  handles it correctly via isMinTTLExpired
- Add test cases verifying delete_ttl_info_min/max metadata in
  system.parts after vertical merge (with and without WHERE clause)

Signed-off-by: murphy-4o <[email protected]>
Made-with: Cursor
@CurtizJ
CurtizJ added this pull request to the merge queue Mar 3, 2026
Merged via the queue into ClickHouse:master with commit 35099ff Mar 3, 2026
287 of 288 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 3, 2026
@antonio2368

Copy link
Copy Markdown
Member

Seems a lot of issues in CI related to it:
#98614
#98692
#98814

@CurtizJ

CurtizJ commented Mar 6, 2026

Copy link
Copy Markdown
Member

I guess the PR with fix is already opened #98946.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow vertical merge with TTL

6 participants