> ## 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.

# max_delay_* MergeTree table settings

> ClickHouse MergeTree table settings in the max_delay_* 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="max_delay_to_insert">
  max\_delay\_to\_insert
</h2>

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

The value in seconds, which is used to calculate the `INSERT` delay, if the
number of active parts in a single partition exceeds the
[parts\_to\_delay\_insert](/docs/reference/settings/merge-tree-settings/parts-to#parts_to_delay_insert) value.

Possible values:

* Any positive integer.

The delay (in milliseconds) for `INSERT` is calculated by the formula:

```code theme={null}
max_k = parts_to_throw_insert - parts_to_delay_insert
k = 1 + parts_count_in_partition - parts_to_delay_insert
delay_milliseconds = pow(max_delay_to_insert * 1000, k / max_k)
```

For example, if a partition has 299 active parts and parts\_to\_throw\_insert
\= 300, parts\_to\_delay\_insert = 150, max\_delay\_to\_insert = 1, `INSERT` is
delayed for `pow( 1 * 1000, (1 + 299 - 150) / (300 - 150) ) = 1000`
milliseconds.

Starting from version 23.1 formula has been changed to:

```code theme={null}
allowed_parts_over_threshold = parts_to_throw_insert - parts_to_delay_insert
parts_over_threshold = parts_count_in_partition - parts_to_delay_insert + 1
delay_milliseconds = max(min_delay_to_insert_ms, (max_delay_to_insert * 1000)
* parts_over_threshold / allowed_parts_over_threshold)
```

For example, if a partition has 224 active parts and parts\_to\_throw\_insert
\= 300, parts\_to\_delay\_insert = 150, max\_delay\_to\_insert = 1,
min\_delay\_to\_insert\_ms = 10, `INSERT` is delayed for `max( 10, 1 * 1000 *
(224 - 150 + 1) / (300 - 150) ) = 500` milliseconds.

<h2 id="max_delay_to_mutate_ms">
  max\_delay\_to\_mutate\_ms
</h2>

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

Max delay of mutating MergeTree table in milliseconds, if there are a lot of
unfinished mutations
