> ## 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_max_* MergeTree table settings

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

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

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

<h2 id="merge_max_block_size">
  merge\_max\_block\_size
</h2>

<SettingsInfoBlock type="NonZeroUInt64" default_value="8192" />

The number of rows that are read from the merged parts into memory.

Possible values:

* Any positive integer.

Merge reads rows from parts in blocks of `merge_max_block_size` rows, then
merges and writes the result into a new part. The read block is placed in RAM,
so `merge_max_block_size` affects the size of the RAM required for the merge.
Thus, merges can consume a large amount of RAM for tables with very wide rows
(if the average row size is 100kb, then when merging 10 parts,
(100kb \* 10 \* 8192) = \~ 8GB of RAM). By decreasing `merge_max_block_size`,
you can reduce the amount of RAM required for a merge but slow down a merge.

<h2 id="merge_max_block_size_bytes">
  merge\_max\_block\_size\_bytes
</h2>

<SettingsInfoBlock type="UInt64" default_value="10485760" />

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

<h2 id="merge_max_bytes_to_prewarm_cache">
  merge\_max\_bytes\_to\_prewarm\_cache
</h2>

<SettingsInfoBlock type="UInt64" default_value="1073741824" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1073741824"},{"label": "Cloud sync"}]}]} />

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

<h2 id="merge_max_dynamic_subcolumns_in_compact_part">
  merge\_max\_dynamic\_subcolumns\_in\_compact\_part
</h2>

<SettingsInfoBlock type="UInt64Auto" default_value="auto" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "auto"},{"label": "Add a new setting to limit number of dynamic subcolumns in Compact part after merge regardless the parameters specified in the data type"}]}]} />

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.

<h2 id="merge_max_dynamic_subcolumns_in_wide_part">
  merge\_max\_dynamic\_subcolumns\_in\_wide\_part
</h2>

<SettingsInfoBlock type="UInt64Auto" default_value="auto" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.11"},{"label": "auto"},{"label": "Add a new setting to limit number of dynamic subcolumns in Wide part after merge regardless the parameters specified in the data type"}]}]} />

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.
