MergeTree tables settings

How many bytes in blocks should be formed for merge operations. By default
has the same value as `index_granularity_bytes`.

## merge\_max\_bytes\_to\_prewarm\_cache[​](#merge_max_bytes_to_prewarm_cache "Direct link to merge_max_bytes_to_prewarm_cache")

Only available in ClickHouse Cloud. Maximal size of part (compact or packed)
to prewarm cache during merge.

## merge\_max\_dynamic\_subcolumns\_in\_compact\_part[​](#merge_max_dynamic_subcolumns_in_compact_part "Direct link to merge_max_dynamic_subcolumns_in_compact_part")

The maximum number of dynamic subcolumns that can be created in every column in the Compact data part after merge.
It allows to control the number of dynamic subcolumns in Compact part regardless of dynamic parameters specified in the data type.

For example, if the table has a column with the JSON(max\_dynamic\_paths=1024) type and the setting merge\_max\_dynamic\_subcolumns\_in\_compact\_part is set to 128,
after merge into the Compact data part number of dynamic paths will be decreased to 128 in this part and only 128 paths will be written as dynamic subcolumns.

## merge\_max\_dynamic\_subcolumns\_in\_wide\_part[​](#merge_max_dynamic_subcolumns_in_wide_part "Direct link to merge_max_dynamic_subcolumns_in_wide_part")

The maximum number of dynamic subcolumns that can be created in every column in the Wide data part after merge.
It allows to reduce number of files created in Wide data part regardless of dynamic parameters specified in the data type.

For example, if the table has a column with the JSON(max\_dynamic\_paths=1024) type and the setting merge\_max\_dynamic\_subcolumns\_in\_wide\_part is set to 128,
after merge into the Wide data part number of dynamic paths will be decreased to 128 in this part and only 128 paths will be written as dynamic subcolumns.

## merge\_selecting\_sleep\_ms[​](#merge_selecting_sleep_ms "Direct link to merge_selecting_sleep_ms")

Minimum time to wait before trying to select parts to merge again after no
parts were selected. A lower setting will trigger selecting tasks in
background\_schedule\_pool frequently which result in large amount of requests
to zookeeper in large-scale clusters

## merge\_selecting\_sleep\_slowdown\_factor[​](#merge_selecting_sleep_slowdown_factor "Direct link to merge_selecting_sleep_slowdown_factor")

The sleep time for merge selecting task is multiplied by this factor when
there's nothing to merge and divided when a merge was assigned

## merge\_selector\_algorithm[​](#merge_selector_algorithm "Direct link to merge_selector_algorithm")

Experimental feature. [Learn more.](/docs/beta-and-experimental-features#experimental-features)

The algorithm to select parts for merges assignment

## merge\_selector\_base[​](#merge_selector_base "Direct link to merge_selector_base")

Affects write amplification of
assigned merges (expert level setting, don't change if you don't understand
what it is doing). Works for Simple and StochasticSimple merge selectors

## merge\_selector\_blurry\_base\_scale\_factor[​](#merge_selector_blurry_base_scale_factor "Direct link to merge_selector_blurry_base_scale_factor")

Controls when the logic kicks in relatively to the number of parts in
partition. The bigger the factor the more belated reaction will be.

## merge\_selector\_enable\_heuristic\_to\_lower\_max\_parts\_to\_merge\_at\_once[​](#merge_selector_enable_heuristic_to_lower_max_parts_to_merge_at_once "Direct link to merge_selector_enable_heuristic_to_lower_max_parts_to_merge_at_once")

Experimental feature. [Learn more.](/docs/beta-and-experimental-features#experimental-features)

Enable heuristic for simple merge selector which will lower maximum limit for merge choice.
By doing so number of concurrent merges will increase which can help with TOO\_MANY\_PARTS
errors but at the same time this will increase the write amplification.

## merge\_selector\_enable\_heuristic\_to\_remove\_small\_parts\_at\_right[​](#merge_selector_enable_heuristic_to_remove_small_parts_at_right "Direct link to merge_selector_enable_heuristic_to_remove_small_parts_at_right")

Enable heuristic for selecting parts for merge which removes parts from right
side of range, if their size is less than specified ratio (0.01) of sum\_size.
Works for Simple and StochasticSimple merge selectors

## merge\_selector\_heuristic\_to\_lower\_max\_parts\_to\_merge\_at\_once\_exponent[​](#merge_selector_heuristic_to_lower_max_parts_to_merge_at_once_exponent "Direct link to merge_selector_heuristic_to_lower_max_parts_to_merge_at_once_exponent")

Experimental feature. [Learn more.](/docs/beta-and-experimental-features#experimental-features)

Controls the exponent value used in formulae building lowering curve. Lowering exponent will
lower merge widths which will trigger increase in write amplification. The reverse is also true.

## merge\_selector\_window\_size[​](#merge_selector_window_size "Direct link to merge_selector_window_size")

How many parts to look at once.

## merge\_total\_max\_bytes\_to\_prewarm\_cache[​](#merge_total_max_bytes_to_prewarm_cache "Direct link to merge_total_max_bytes_to_prewarm_cache")

Only available in ClickHouse Cloud. Maximal size of parts in total to prewarm
cache during merge.

## merge\_tree\_clear\_old\_broken\_detached\_parts\_ttl\_timeout\_seconds[​](#merge_tree_clear_old_broken_detached_parts_ttl_timeout_seconds "Direct link to merge_tree_clear_old_broken_detached_parts_ttl_timeout_seconds")

Obsolete setting, does nothing.

## merge\_tree\_clear\_old\_parts\_interval\_seconds[​](#merge_tree_clear_old_parts_interval_seconds "Direct link to merge_tree_clear_old_parts_interval_seconds")

Sets the interval in seconds for ClickHouse to execute the cleanup of old
parts, WALs, and mutations.

Possible values:

- Any positive integer.

## merge\_tree\_clear\_old\_temporary\_directories\_interval\_seconds[​](#merge_tree_clear_old_temporary_directories_interval_seconds "Direct link to merge_tree_clear_old_temporary_directories_interval_seconds")

Sets the interval in seconds for ClickHouse to execute the cleanup of old
temporary directories.

Possible values:

- Any positive integer.

## merge\_tree\_enable\_clear\_old\_broken\_detached[​](#merge_tree_enable_clear_old_broken_detached "Direct link to merge_tree_enable_clear_old_broken_detached")

Obsolete setting, does nothing.

## merge\_with\_recompression\_ttl\_timeout[​](#merge_with_recompression_ttl_timeout "Direct link to merge_with_recompression_ttl_timeout")

Minimum delay in seconds before repeating a merge with recompression TTL.

## merge\_with\_ttl\_timeout[​](#merge_with_ttl_timeout "Direct link to merge_with_ttl_timeout")

Minimum delay in seconds before repeating a merge with delete TTL.

## merge\_workload[​](#merge_workload "Direct link to merge_workload")

Used to regulate how resources are utilized and shared between merges and
other workloads. Specified value is used as `workload` setting value for
background merges of this table. If not specified (empty string), then
server setting `merge_workload` is used instead.

**See Also**

- [Workload Scheduling](/docs/operations/workload-scheduling)

## min\_absolute\_delay\_to\_close[​](#min_absolute_delay_to_close "Direct link to min_absolute_delay_to_close")

Minimal absolute delay to close, stop serving requests and not
return Ok during status check.

## min\_age\_to\_force\_merge\_on\_partition\_only[​](#min_age_to_force_merge_on_partition_only "Direct link to min_age_to_force_merge_on_partition_only")

Whether `min_age_to_force_merge_seconds` should be applied only on the entire
partition and not on subset.

By default, ignores setting `max_bytes_to_merge_at_max_space_in_pool` (see
`enable_max_bytes_limit_for_min_age_to_force_merge`).

Possible values:

- true, false

## min\_age\_to\_force\_merge\_seconds[​](#min_age_to_force_merge_seconds "Direct link to min_age_to_force_merge_seconds")

Merge parts if every part in the range is older than the value of
`min_age_to_force_merge_seconds`.

By default, ignores setting `max_bytes_to_merge_at_max_space_in_pool`
(see `enable_max_bytes_limit_for_min_age_to_force_merge`).

Possible values:

- Positive integer.