Skip to content

Fit the insert pipeline and merges into a small server's memory - #116083

Merged
alexey-milovidov merged 78 commits into
masterfrom
clickbench-small-memory
Oct 25, 2026
Merged

alexey-milovidov merged 78 commits into
masterfrom
clickbench-small-memory

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Loading ClickBench on a t3a.small (2 vCPU, 2 GiB) fails long before the data is in:

Code: 241. DB::Exception: (total) memory limit exceeded: would use 1.34 GiB
(attempt to allocate chunk of 4.16 MiB), current RSS: 944.02 MiB, maximum: 1.33 GiB.
(query: INSERT INTO hits SELECT * FROM file('hits_*.parquet'))

The insert pipeline sizes its buffers from settings picked for large servers, and the few places that already scale with the memory budget use fractions of it that do not match how many copies of that budget the pipeline really holds. Four things dominate the peak, measured on a t3a.small emulation (a cgroup with 2 CPUs, max_server_memory_usage pinned to the 1.33 GiB from the report above) loading the 105-column ClickBench hits table from the 100 partitioned Parquet files:

Wide-part write buffers. Every stream of a wide part preallocates two buffers of max_compress_block_size — the file buffer and the compressor's block buffer — so 105 columns reserve 210 MiB before a byte is written, and every concurrent merge reserves it again. Adaptive write buffers exist for exactly this, but were gated behind min_columns_to_activate_adaptive_write_buffer = 500 columns, which a 105-column table never reaches. The new max_memory_ratio_to_activate_adaptive_write_buffer (default 1/32) also activates them when the preallocation would take that share of the memory limit.

Insert squashing. The squashing stage does not hold one block of min_insert_block_size_bytes but about five: the transform accumulates the next block while the previous one is concatenated, the concatenated block is alive in the sink, and blocks are measured by logical size while the PODArrays behind them round their capacity up. The existing low-memory cap was a ninth of the budget, so the stage could take half the server. It is now capped so those copies stay within 40% of the budget.

Parquet reader. The reader keeps a whole pipeline of input_format_parquet_prefer_block_bytes blocks in flight — prefetched, decoded and ready to deliver — about 290 MiB of live memory for the 16 MiB default on this table. Its cap moves from a 64th to a 256th of the budget.

Merges of very wide tables. A merge keeps one block from every source part alive at once, and every column of every one of those blocks costs at least a minimum allocation whatever the data size, so the fixed cost grows with source parts × columns. Merging the default 100 parts of system.metric_log — 2032 columns, a few thousand rows — peaks at about 700 MiB. On a small server that merge fails with MEMORY_LIMIT_EXCEEDED, its source parts stay where they were, and the next selection round picks the same parts again: the table stops compacting altogether while its part count keeps growing, and the server ends up pinned at its memory limit with every query failing. The new merge_memory_estimate_per_source_part_column (default 4096) lowers max_parts_to_merge_at_once so one merge's fixed cost stays within a sixteenth of the memory limit. Ordinary tables, and even very wide tables on a large server, are unaffected.

All four caps are no-ops on a server with several GiB of RAM or more, and each new setting can be set to 0 to switch its trigger off.

Result on the emulated t3a.small, running the unmodified ClickBench clickhouse scripts:

before after
INSERT INTO hits SELECT * FROM file('hits_*.parquet') fails after 3 s, 0 rows 99 997 497 rows in 962 s, peak 929 MiB
the 43 queries not reachable all 43 run, no memory errors

A single system.metric_log merge goes from 675 MiB over 99 source parts to 85 MiB over 6.

Changelog category (leave one):

  • Improvement

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

Make INSERT and background merges fit into the memory of a small server. On a machine with a couple of GiB of RAM, INSERT ... SELECT into a table with many columns used to fail with MEMORY_LIMIT_EXCEEDED because the write buffers, the squashing stage and the Parquet reader were sized for large servers; and merges of very wide tables such as system.metric_log used to fail and never make progress, leaving the table to accumulate parts forever. All of these now scale with max_server_memory_usage. New MergeTree settings max_memory_ratio_to_activate_adaptive_write_buffer and merge_memory_estimate_per_source_part_column control the last two; set either to 0 for the previous behavior.


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

Version info

  • Merged into: 26.11.1.776-master (included in 26.11 and later)

On a machine with a couple of GiB of RAM, loading ClickBench fails long before
the data is in:

    Code: 241. DB::Exception: (total) memory limit exceeded: would use 1.34 GiB
    (attempt to allocate chunk of 4.16 MiB), current RSS: 944.02 MiB, maximum: 1.33 GiB.
    (query: INSERT INTO hits SELECT * FROM file('hits_*.parquet'))

The pipeline sizes its buffers from settings picked for large servers, and the
few places that already scale with memory use fractions of the budget that do
not match how many copies of it the pipeline actually holds. Measured on a
`t3a.small` emulation (2 CPUs, `max_server_memory_usage` = 1.33 GiB) inserting
the 105-column ClickBench `hits` table from Parquet:

  * A wide part preallocates two buffers of `max_compress_block_size` per stream,
    so 105 columns reserve 210 MiB before a byte is written, and every concurrent
    merge reserves it again. Adaptive write buffers exist for exactly this, but
    were gated behind `min_columns_to_activate_adaptive_write_buffer` = 500.
    Activate them by memory too, via the new
    `max_memory_ratio_to_activate_adaptive_write_buffer`.

  * The squashing stage was capped at a ninth of the memory budget, but the
    pipeline holds roughly five such blocks at once. Cap it so those copies stay
    within 40% of the budget.

  * The Parquet reader keeps a pipeline of `input_format_parquet_prefer_block_bytes`
    blocks in flight, ~290 MiB of live memory for the 16 MiB default, so its cap
    needed to be a much smaller fraction of the budget.

  * A merge keeps one block from every source part alive, costing a minimum
    allocation per (source part, column) whatever the data size. Merging the
    default 100 parts of `system.metric_log` (2032 columns) peaks at ~700 MiB,
    fails, leaves the parts behind, and the next round selects the same parts:
    the table never compacts again and the server sits at its memory limit. The
    new `merge_memory_estimate_per_source_part_column` narrows such merges.

With all four, the 100 Parquet files load in full at a 1.33 GiB limit with a
929 MiB peak, and all 43 ClickBench queries run.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [63bb69b]

Summary: ✅


AI Review

Summary

The PR scales wide-part write buffers, insert squashing, Parquet batches, and merge fan-in with the server memory limit. One existing P1 remains: projection-child merges can bypass the horizontal memory budget. Reproduced with the current PR-head Fast test binary, so changes are required.

Findings

❌ Blockers

  • P1 — Projection-child algorithm prediction ignores absent columns. src/Storages/MergeTree/Compaction/MergeSelectorApplier.cpp:679–684. getAffordablePartsToMergeProjection counts the current projection schema when checking vertical eligibility. The child MergeTask first removes columns absent from every source projection part and without defaults. Selection can consequently grant the vertical price to a child that executes horizontally, admitting more source parts than the configured memory budget allows and exposing wide projected tables to repeated MEMORY_LIMIT_EXCEEDED failures.

    Reproduction at head 63bb69bb4928b449ae47ed667a5683a615b10501: a 2 GiB server limit, 16 original UInt64 columns, projection SELECT * EXCEPT (c11,c12,c13,c14,c15) ORDER BY c0, eight one-row wide parts, then five added columns without defaults; deduplicate_merge_projection_mode = 'ignore', estimate 4194304, and vertical gathering threshold 11. Selection merges eight parents vertically, then eight projection parts horizontally over 11 retained columns. The projection has only ten gathering columns; even pricing its retained columns permits only two source parts.

    Account for absent columns in the selected projection parts before allowing vertical pricing. This is the existing unresolved finding; no duplicate inline comment was posted.

Tests
  • ⚠️ Add a focused stateless regression for the projection schema transition above. Assert that the selected width respects the horizontal child budget; a parent Vertical result alone does not validate the child's algorithm. The local reproduction is recorded in tmp/pr116083_build/test_projection_absent.log, with parent/child execution traces in tmp/pr116083_server/server.log.
Final Verdict

Status: ⚠️ Request changes. Correct projection-child eligibility and memory pricing for absent columns, and cover the selected width with a regression test.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Aug 24, 2026
Master moved to 26.9 while this branch was open, so the settings history
check asks for the two new MergeTree settings under a 26.9 block.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 63bb69bb4928b449ae47ed667a5683a615b10501 was not compared: the CI logs cluster did not answer (exception 241, code 500: { "meta": [ { "name": "file", "type": "String" }, { "name…).

See the job log for details.

After merging master, the branch had two `addSettingsChanges` calls for version 26.9 in
`getMergeTreeSettingsChangesHistory`, and `addSettingsChanges` throws a logical error
("Detected duplicate version") on the first use. Fold the two new settings into the
existing 26.9 block.
`num_columns * merge_memory_estimate_per_source_part_column` could wrap around for
absurdly large (but legal) values of the setting, making the cap non-monotonic and, when
the product wrapped to zero, dividing by zero. Divide the budget by the two factors one
after another instead of dividing by their product - no multiplication, no overflow.
…ges too

The memory-derived cap was only threaded into `TTLPartDropMergeSelector`, so a wide table
with a row-delete or recompression TTL could still pick a merge too wide to fit in memory
and get stuck failing with `MEMORY_LIMIT_EXCEEDED`. Pass the memory-derived part of the
cap (and only it - `max_parts_to_merge_at_once` deliberately does not constrain these
selectors) to `TTLRowDeleteMergeSelector` and `TTLRecompressMergeSelector` as well.

Completes the constructor call sites changed in the previous commit.
…view pipelines

The tighter 5x/40% cap only existed in `InterpreterInsertQuery`, while dependent
materialized-view pipelines kept the older, looser `0.9 * limit / 8` formula in a local
helper of `InsertDependenciesBuilder`. Expose `capInsertBlockSizeBytesToMemoryLimit` from
`InterpreterInsertQuery.h` and use it in both places, so the cap is applied symmetrically
to the direct sink and the view-side squashing.
…imit, not an eighth

The code uses `inverse_share_of_the_limit = 16` while the description of
`merge_memory_estimate_per_source_part_column` said "an eighth".
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116083&sha=988b14f0b3cd3491cdf3daa3d8c088cec3bc4ccf&name_0=PR&name_1=Integration%20tests%20(arm_binary%2C%20distributed%20plan%2C%201%2F4) and provide a fix in a separate PR. If the fix is already in progress, link it here.

The failed test is test_default_session_user/test.py::test_config_reload_prometheus_handlers_switch_to_fixed_user (AssertionError on contains_in_log(... will reload prometheus-write-reload)). It is unrelated to this PR: CIDB shows it failing across many PRs and on master itself on 2026-08-24 through 2026-08-26, and I found no open issue or fix PR for it.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already merged: #116109 (merged 2026-08-24 18:26:11Z, 073712a9e380). It is merged rather than open, so an open-PR search does not surface it.

Root cause: the background ConfigReloader poller (config_reload_interval_ms, default 2000 ms) can pick up the config edit before the test's own SYSTEM RELOAD CONFIG. updateServers then compares the edited config against itself, because previous_config is the last applied configuration, so default_session_user_changed stays false and <default_session_user> had been changed, will reload ... is never written at all. The line is lost, not late, which is why no amount of polling on the assertion side would have fixed it. The fix pins config_reload_interval_ms to one hour on all three instances of that module so SYSTEM RELOAD CONFIG is the only reloader, and asserts the pin took effect in the fixture.

Your run predates it. The failing job's own job.log records the master tip it merged as ef23be3eeb0420, and compare/073712a9e380...ef23be3eeb0420 returns status=behind, ahead_by=0, so the tested tree is an ancestor of the fix merge. Consistently, tests/integration/test_default_session_user/configs/config_reloader.xml returns 404 at that tip and resolves at master. The job started at 18:07:24Z, 19 minutes before the fix merged.

Master has been clean since. For this test with pull_request_number = 0 AND head_ref = 'master' after the merge timestamp, CIDB has 301 OK and 0 FAIL/ERROR.

One correction on the 08-25 and 08-26 part: those runs are 26.8, not master. pull_request_number = 0 covers release branches as well as master, and every failure of this test in that window is either head_ref = '26.8' or a backport PR onto 26.8. There is no true-master failure after the merge.

That leaves one real residual: 26.8 does not have the fix, so it still fails there. @alexey-milovidov, could you apply v26.8-must-backport to #116109? 26.8 is the newest active release branch, so the label expands to exactly 26.8, and the cherry-pick is trivially clean: test.py on 26.8 is byte-identical to the blob the patch was written against, and configs/config_reloader.xml does not exist there yet.

…mory

# Conflicts:
#	src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp
…mory estimate too

`merge_memory_estimate_per_source_part_column` previously reached only the `Simple` and
`StochasticSimple` selectors, so a small server with `merge_selector_algorithm = 'Trivial'` could
keep selecting the same too-wide merge of a very wide table and never compact it. Thread the
memory-derived cap into `TrivialMergeSelector` as well; its fixed 10-part window is unchanged
otherwise, and the configured `max_parts_to_merge_at_once` deliberately still does not constrain it.
…tio provides

The round-trip in 05038 stays green whether or not the ratio trigger fires, so it does not prove
the new condition is wired in. Add a test modelled on
`03770_min_columns_to_activate_adaptive_write_buffer`: with the column-count trigger disabled, a
wide write of a 300-column table only fits into a 50 MiB `max_memory_usage` budget because
`max_memory_ratio_to_activate_adaptive_write_buffer` switches it to adaptive buffers, and the
`part_log` peak-memory check pins the merge path too.
…and keep `TTLDrop` on the configured width

Two findings from the review:

- The merge-side memory contract was incomplete for tables with projections. `MergeTask` and
  `MutateTask` built `pre_calculate_squash` and `projection_squashes` from the raw
  `min_insert_block_size_bytes`, so a background merge kept multi-hundred-MiB buffers alive on a
  small server even after `getAffordablePartsToMergeAtOnce` had narrowed the source-part fan-in.
  Those buffers are the same kind of block-sized copies an `INSERT` pipeline holds, so bound them
  with the same helper. `capInsertBlockSizeBytesToMemoryLimit` moved out of `InterpreterInsertQuery`
  into its own translation unit, so the storage code does not have to include the interpreter.

- `merge_memory_estimate_per_source_part_column` models the cost of keeping one block per
  (source part, column) alive, and that cost does not exist for a `TTLDrop` merge of a table with
  only an unconditional rows TTL: `MergeTask` short-circuits it before building the read pipeline.
  Capping it there would only stretch TTL cleanup of wide tables into tiny drop batches for no
  memory benefit, so `TTLPartDropMergeSelector` stays on the configured `max_parts_to_merge_at_once`
  in that case. When any other TTL family is present the pipeline is built as usual and the
  memory-derived cap applies like it does to the other merges.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The sole CI red on 6bfb003518cd was Stress test (amd_asan_ubsan): AddressSanitizer: heap-use-after-free at src/Processors/Executors/ExecutingGraph.cpp:422 in ExecutingGraph::updateNode (report).

It is unrelated to this PR — nothing here touches the pipeline executor — and a fix is already in progress: #116103 (and #117129, which carries the same executor edge fix). Not yet on master, so merging the base branch does not clear it; the next run may still hit it.

The branch has since been merged with master and the two review findings addressed.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, on the residual from your earlier reply: there is no v26.8-must-backport label in the repository — the per-version backport labels currently stop at v26.7-must-backport. So the label cannot simply be applied to #116109; getting the fix onto 26.8 needs either that label to be created first or a manual cherry-pick. Leaving that to release management rather than creating a repository label from here.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov v26.8-must-backport does exist and the robot route is live: #117128 received that label on 2026-08-30 at 08:07:59Z and robot-ch-test-poll2 opened the 26.8 backport #117132 twenty minutes later. gh api repos/ClickHouse/ClickHouse/labels --paginate --jq '.[].name' | grep must-backport lists it; note that a default gh label list returns only 30 of the repo's 242 labels.

So nothing needs creating and no cherry-pick by hand is required. #116109 still carries no backport label, and since it merged CIDB has 792 OK and 0 failures for this test on master, against 148 OK and 3 failures on 26.8, the last on 2026-08-27. The label on #116109 is the only remaining step.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Very good.

@alexey-milovidov alexey-milovidov self-assigned this Sep 3, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 25, 2026
Merged via the queue into master with commit ae6fcab Oct 25, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the clickbench-small-memory branch October 25, 2026 19:08
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 25, 2026
cwurm added a commit to cwurm/ClickHouse that referenced this pull request Oct 26, 2026
…cation

Deduplication of async inserts supports only one view block per source
block: `DeduplicationInfo::setViewBlockNumber` throws `NOT_IMPLEMENTED` for
any later block. The `SquashingTransform` after the view query in
`ExecutingInnerQueryFromViewTransform::process` emitted a block as soon as
`min_insert_block_size_rows` or `min_insert_block_size_bytes` was reached,
so a view whose output for one flush exceeded them failed the whole flush,
even when the view reduces rows (e.g. a `GROUP BY` with more than ~1M
groups). The source table had already committed, leaving it inconsistent
with the view targets.

This got more likely with ClickHouse#116083,
which caps that byte threshold by a share of the server memory limit split
between all squashing pipelines of the insert, so on smaller servers or
with many views the view output is split, and the flush rejected, at much
smaller sizes than `min_insert_block_size_bytes`.

With async insert and `deduplicate_blocks_in_dependent_materialized_views`,
ignore those thresholds so the squashing emits once on finish, one block
per source block. The memory cap of `capInsertBlockSizeBytesToMemoryLimit`
still applies, so a view output above it is split and rejected as before
instead of being accumulated without bound. Inserts whose view output stays
below the thresholds already got a single block and are unaffected; only
inserts that previously failed change behavior.

Closes: ClickHouse#127370
Related: ClickHouse#116083

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cwurm added a commit to cwurm/ClickHouse that referenced this pull request Oct 26, 2026
…cation

Deduplication of async inserts supports only one view block per source
block: `DeduplicationInfo::setViewBlockNumber` throws `NOT_IMPLEMENTED` for
any later block. The `SquashingTransform` after the view query in
`ExecutingInnerQueryFromViewTransform::process` emitted a block as soon as
`min_insert_block_size_rows` or `min_insert_block_size_bytes` was reached,
so a view whose output for one flush exceeded them failed the whole flush,
even when the view reduces rows (e.g. a `GROUP BY` with more than ~1M
groups). The source table had already committed, leaving it inconsistent
with the view targets.

This got more likely with ClickHouse#116083,
which caps that byte threshold by a share of the server memory limit split
between all squashing pipelines of the insert, so on smaller servers or
with many views the view output is split, and the flush rejected, at much
smaller sizes than `min_insert_block_size_bytes`.

With async insert and `deduplicate_blocks_in_dependent_materialized_views`,
ignore those thresholds so the squashing emits once on finish, one block
per source block. The memory cap of `capInsertBlockSizeBytesToMemoryLimit`
still applies, so a view output above it is split and rejected as before
instead of being accumulated without bound. Inserts whose view output stays
below the thresholds already got a single block and are unaffected; only
inserts that previously failed change behavior.

Closes: ClickHouse#127370
Related: ClickHouse#116083

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 3, 2026
…ch-small-memory"

This reverts commit ae6fcab, reversing changes made to 2f0acc8.

The PR was merged without an approving review. It changes about 1000 lines of merge selection code (`MergeSelectorApplier`, merge predicates, `SimpleMergeSelector`, `TTLMergeSelector`) together with a new cap on insert squashing that depends on the server memory limit and the number of materialized views, and there is no setting to disable the insert cap. The insert cap makes the block boundaries of a retried insert depend on the memory limit and the set of materialized views at the time of the attempt, which can break insert deduplication on retry.

Related: ClickHouse#116083
alexey-milovidov added a commit that referenced this pull request Nov 3, 2026
…ations

Master reverted #116083, which removed
`merge_forced_horizontal` from `StorageMergeTree::selectPartsToMerge` and the
`max_memory_ratio_to_activate_adaptive_write_buffer` setting together with its
adaptive write buffer trigger in `MergeTreeDataPartWriterWide`.

Resolution:
- Drop the `merge_forced_horizontal` parameter, keep this PR's `user_initiated`,
  `deduplicate` and `cleanup` parameters.
- Remove the memory-ratio adaptive rule from the merge memory estimate in
  `CompactionStatistics`, since the writer no longer applies it.
- Delete test `05461_merge_memory_reservation_memory_ratio_adaptive`, which tested
  the reverted trigger, and drop the removed setting from the other tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yariks5s added a commit that referenced this pull request Nov 3, 2026
…_insert_block_size_bytes`, as `PartMergerWriter` does after the revert of #116083
PedroTadim added a commit that referenced this pull request Nov 4, 2026
…ate_adaptive_write_buffer

`max_memory_ratio_to_activate_adaptive_write_buffer` was reverted on master
(#128706 reverts #116083 "clickbench-small-memory"), so it no longer exists in
the binary CI builds. The randomizer still injected
`--max_memory_ratio_to_activate_adaptive_write_buffer` into every test's client
args, so every test that drew it failed with return code 40
`Code: 552 ... Unrecognized option ... (UNRECOGNIZED_ARGUMENTS)` regardless of
content - a systemic storm across the targeted and all flaky-check jobs ("Too
many test failures"). Comment the entry out (keep it for re-enable if the
setting ever returns). `min_columns_to_activate_adaptive_write_buffer` and
`merge_memory_estimate_per_source_part_column` are unaffected (the latter is
not randomized).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=106734&sha=9b5082447401231d07326cb0c3b15e2152dfbdd8&name_0=PR
PR: #106734

Co-Authored-By: Claude Opus 4.8 <[email protected]>
PedroTadim added a commit that referenced this pull request Nov 4, 2026
Randomize many more server and MergeTree settings in clickhouse-test, and pin
or narrow the tests whose observable plan/EXPLAIN/spill/cache/stats output the
extra randomization legitimately changes (results unchanged). Output-changing
settings that make poor randomization candidates are commented out of the
randomizer (kept, so they can be re-enabled); one-off non-bug test failures are
pinned to the setting's default in the test itself. Each pin carries a comment
explaining which randomized setting it guards against.

Rebased onto current master and squashed. The reverted MergeTree setting
`max_memory_ratio_to_activate_adaptive_write_buffer` (#128706 reverts #116083)
is no longer randomized.

PR: #106734

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 4, 2026
Master reverted the merge width memory estimate (#116083), so the compaction
files take master's version: `projections_with_changed_source` only priced the
rebuilt projections in that estimate. Its test
`05460_merge_width_memory_estimate_shadowed_projection_source` is removed with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 5, 2026
…everted in master

The test covered how `predictVerticalMerge` and `getAffordablePartsToMergeProjection`
price merges into `Parquet` parts with `merge_memory_estimate_per_source_part_column`.
That merge memory estimate was removed from master by the revert of
#116083 (`f74b3d2d8d65`), together with the
code that this PR had adjusted, so the test fails with `UNKNOWN_SETTING`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
subkanthi pushed a commit to subkanthi/ClickHouse that referenced this pull request Nov 10, 2026
The Parquet reader keeps a whole pipeline of `input_format_parquet_prefer_block_bytes`
blocks in flight: prefetched, decoded and ready to deliver. Measured on the 105-column
ClickBench `hits` table, the default 16 MiB preferred block size costs about 290 MiB of
live reader memory, so a cap of a 64th of the budget did not help a small server. With
the default setting the new cap binds only below about 4.4 GiB of memory limit.

This is a part of ClickHouse#116083 reverted in
ClickHouse#128706, re-submitted separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
subkanthi pushed a commit to subkanthi/ClickHouse that referenced this pull request Nov 10, 2026
…by default

The squashing stages of an `INSERT` cap `min_insert_block_size_bytes` by the memory
limit. The cap was hardcoded as 0.9 / 8 of the limit, could not be disabled, and was
too high for a small server: a squashing stage holds several block-sized copies at once.

The new setting `insert_squashing_max_memory_ratio` (default 1/16) replaces the
hardcoded fraction. The cap depends only on the memory limit and the setting, not on
the number of materialized views or insert streams. `0` disables the cap, and `0.1125`
gives the previous behavior.

This is a part of ClickHouse#116083 reverted in
ClickHouse#128706, re-submitted in a reduced form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-gh Bot pushed a commit that referenced this pull request Nov 20, 2026
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md.

Changelog-revert: 127836 124816 Revert "Avoid building stream names and substreams cache keys for every block in MergeTreeReaderWide"
Changelog-revert: 128706 116083 Revert "Fit the insert pipeline and merges into a small server's memory"
Changelog-revert: 128760 128658 Revert "Prewarm macOS code signature verification of the clickhouse binary after linking"
Changelog-revert: 128947 127422 Revert "[GPU] `GDeflate` compression codec on the CPU"
Changelog-revert: 129099 128947 Revert "Revert "[GPU] `GDeflate` compression codec on the CPU""
Changelog-revert: 129310 127149 Revert "Mark a query as cancelled in the process list when its TCP client cancels it"
Changelog-revert: 129311 129310 Revert "Revert "Mark a query as cancelled in the process list when its TCP client cancels it""
Changelog-revert: 129862 129425 Revert "Add 7 tests for coverage gaps in 5 components"
Changelog-revert: 129863 129862 Fix `GLOBAL IN` in projection `WHERE` with parallel replicas; restore coverage tests
Changelog-revert: 129986 122871 Revert "Search long integer slices in 512-byte chunks on AArch64 in `hasAll` and `hasAny`"
Changelog-revert: 130046 129986 Revert "Revert "Search long integer slices in 512-byte chunks on AArch64 in `hasAll` and `hasAny`""
Changelog-revert: 130368 114729 Revert "CI: run the full test suite only when review threads are resolved"
Changelog-revert: 130509 130368 Revert "Revert "CI: run the full test suite only when review threads are resolved""
Changelog-revert: 130531 114923 Revert "Make a table read by a scalar subquery in a CONSTRAINT a loading dependency"
Changelog-revert: 131043 129464 Revert "Sync shared files changed by the private `AmberMap` PR"
Changelog-revert: 131045 130793 Revert "Fix wrong ORDER BY ... LIMIT results on Delta Lake tables with column mapping"
Changelog-revert: 131270 128764 Re-enable the adaptive aggregator for queries generated from PromQL
Changelog-revert: 131424 122826 Revert "Forbid renaming the source of incremental refreshable views"
Changelog-revert: 131562 131454 Revert "Build the symbol index in the background at server startup"
Changelog-revert: 131638 131562 Revert "Revert "Build the symbol index in the background at server startup""
Changelog-revert: 131691 130864 Revert "Use one source instead of N for parallel_inserts of AzureQueue/S3Queue"
Changelog-revert: 131765 119685 Revert "Enable `-mbranch-protection=pac-ret` on ARM"
Changelog-deleted-entry: 116083 [Performance Improvement] [section] * Reduce memory use for `INSERT` and background merges on servers with a few GiB of RAM. Write buffers, insert squashing, the `Parquet` reader and merge selection now scale with `max_server_memory_usage`, avoiding `MEMORY_LIMIT_EXCEEDED` during wide-table inserts and merges that repeatedly fail without reducing the part count. New `MergeTree` settings `max_memory_ratio_to_activate_adaptive_write_buffer` and `merge_memory_estimate_per_source_part_column` control adaptive write buffers and merge selection, respectively; set either to `0` to disable that adjustment. [#116083](#116083) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Changelog-deleted-entry: 119685 [Build/Testing/Packaging Improvement] [raw] * Build the `C` and `C++` code of the ARM binaries with `-mbranch-protection=pac-ret`, which signs the return address so that overwriting it on the stack cannot redirect control flow; the AArch64 `.S` sources that key off `__ARM_FEATURE_PAC_DEFAULT` opt into the same signing. Sanitizer builds are excluded, because the sanitizer runtimes do not strip the signature when they unwind. [#119685](#119685) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Changelog-deleted-entry: 122826 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Forbid renaming the source of incremental refreshable views closes #[#120082](#120082). [#122826](#122826) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
Changelog-deleted-entry: 128658 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Prewarm macOS code signature verification of the clickhouse binary after linking. [#128658](#128658) ([Azat Khuzhin](https://github.com/azat)).
Changelog-deleted-entry: 128764 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Disable the adaptive aggregator for queries generated from PromQL. [#128764](#128764) ([Vitaly Baranov](https://github.com/vitlibar)).
Changelog-deleted-entry: 129464 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Sync shared files changed by the private `AmberMap` PR. [#129464](#129464) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
Changelog-deleted-entry: 130793 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed wrong results of `ORDER BY ... LIMIT` on a Delta Lake table with column mapping when a renamed column has the name that another column is stored under: the top-K dynamic filter (`use_top_k_dynamic_filtering`) compared the other column against the threshold and dropped rows of the true result. [#130793](#130793) ([Groene AI](https://github.com/groeneai)).
Changelog-deleted-entry: 130864 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Use one source instead of N for parallel_inserts of AzureQueue/S3Queue. [#130864](#130864) ([Azat Khuzhin](https://github.com/azat)).
@clickhouse-gh clickhouse-gh Bot added comp-merges Merges of data parts: choosing what to merge (merge selectors, merge predicates, part collectors)... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-merges Merges of data parts: choosing what to merge (merge selectors, merge predicates, part collectors)... memory When memory usage is higher than expected 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.

3 participants