> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# merge_selector_* MergeTree table settings

> ClickHouse MergeTree table settings in the merge_selector_* generated group.

These settings are available in [system.merge\_tree\_settings](https://clickhouse.com/docs/reference/system-tables/merge_tree_settings.md) and are autogenerated from ClickHouse source.

## merge\_selector\_algorithm

[Experimental feature](https://clickhouse.com/docs/reference/settings/beta-and-experimental-features.md#experimental-features)

Type

MergeSelectorAlgorithm

Default

Simple

The algorithm to select parts for merges assignment

## merge\_selector\_base

Type

Float

Default

5

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

Type

UInt64

Default

0

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

Type

Bool

Default

1

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

Type

Bool

Default

1

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

[Experimental feature](https://clickhouse.com/docs/reference/settings/beta-and-experimental-features.md#experimental-features)

Type

UInt64

Default

5

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\_min\_age\_to\_disable\_right\_tail\_heuristic

Type

UInt64

Default

0

If greater than zero and `merge_selector_enable_heuristic_to_remove_small_parts_at_right` is enabled,
disables that heuristic for ranges where every part is at least this many seconds old. `0` disables this check.
Works for Simple and StochasticSimple merge selectors.

## merge\_selector\_small\_parts\_max\_age

Type

UInt64

Default

600

Age limit in seconds for the small-parts restriction: as soon as any part in a range
exceeds this age, the restriction from `merge_selector_small_parts_min_count` is lifted,
so backlogs of stale small parts can still merge even if the range is shorter than
`merge_selector_small_parts_min_count`. Works for Simple and StochasticSimple merge selectors,
and only for background merge selection: aggressive selection (`OPTIMIZE` without `FINAL`)
ignores the `small_parts_*` settings.

## merge\_selector\_small\_parts\_min\_count

Type

UInt64

Default

0

When all parts in a merge range are small (below `merge_selector_small_parts_threshold`)
and fresh (below `merge_selector_small_parts_max_age`), require at least this many parts
to allow the merge. Reduces the number of merge operations under rapid small-part insertion.
0 means disabled. Works for Simple and StochasticSimple merge selectors.

The gate applies to background merge selection only. Aggressive selection - `OPTIMIZE`
without `FINAL` - is an explicit user request that ignores part novelty, so it ignores this
setting and merges small fresh parts regardless of their count.

The selector never considers merge candidates wider than `max_parts_to_merge_at_once`, nor
candidates reaching further back than `merge_selector_window_size` parts, so configuring
either of them below this minimum is a contradictory configuration: small fresh parts then
merge only after `merge_selector_small_parts_max_age` (or earlier, once force merge applies by
`min_age_to_force_merge_seconds` or `min_partition_age_to_force_merge_seconds`). Keep both at
or above this minimum.
(If the built-in fullness heuristic temporarily lowers its effective cap below this minimum,
the selector still considers the first all-small, all-fresh candidate of this width. Stale or
large candidates, and candidates that already qualify for force merge by
`min_age_to_force_merge_seconds` or `min_partition_age_to_force_merge_seconds`, retain the
lowered cap.)

## merge\_selector\_small\_parts\_threshold

Type

UInt64

Default

10485760

Size threshold in bytes: a merge range is considered "all small parts" when every part
is below this size. Used together with `merge_selector_small_parts_min_count`.
Works for Simple and StochasticSimple merge selectors, and only for background merge
selection: aggressive selection (`OPTIMIZE` without `FINAL`) ignores the `small_parts_*`
settings.

## merge\_selector\_window\_size

Type

UInt64

Default

1000

How many parts to look at once.
