> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# min_* MergeTree 表设置

> 属于 min_* 分组的 ClickHouse MergeTree 表设置。

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["版本", "默认值", "注释"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        版本历史
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置可在 [system.merge\_tree\_settings](/zh/reference/system-tables/merge_tree_settings) 中查看，且由 ClickHouse 源代码自动生成。

## min\_absolute\_delay\_to\_close

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

在关闭、停止处理请求并且状态检查不再返回 Ok 之前的最小绝对延迟。

## min\_columns\_to\_activate\_adaptive\_write\_buffer

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "500"},{"label": "新设置"}]}]} />

通过使用自适应写入缓冲区，可降低包含大量列的表的内存使用量。

该值会与宽分片写入的流数量进行比较，后者可能远超列数：包含许多桶的 `Map`，或深度嵌套的 `Array` 或 `Tuple`，单个列会写入许多流，且每个流都会分配一个写入缓冲区。

可选值：

* 0 - 禁用
* 1 - 始终启用

## min\_compress\_block\_size

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

写入下一个标记时，触发压缩所需的未压缩数据块的最小大小。你也可以在全局设置中指定此设置 (参见 [min\_compress\_block\_size](/zh/reference/settings/merge-tree-settings/min#min_compress_block_size) 设置) 。创建表时指定的值会覆盖此设置的全局值。

## min\_index\_granularity\_bytes

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

数据粒度的最小允许大小 (单位：字节) 。

用于防止因误操作创建
`index_granularity_bytes`
极低的表。

## min\_marks\_to\_honor\_max\_concurrent\_queries

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

应用 [max\_concurrent\_queries](/zh/reference/settings/merge-tree-settings/max#max_concurrent_queries)
设置时，查询至少需要读取的标记数。

<Note>
  查询仍会受到其他 `max_concurrent_queries` 设置的限制。
</Note>

可能的值：

* 正整数。
* `0` — 已禁用 (`max_concurrent_queries` 限制不应用于任何查询) 。

**示例**

```xml theme={null}
<min_marks_to_honor_max_concurrent_queries>10</min_marks_to_honor_max_concurrent_queries>
```

## min\_merge\_bytes\_to\_use\_direct\_io

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

合并操作中，使用直接 I/O 访问存储磁盘所需的最小数据量。合并数据分区片段时，ClickHouse 会计算所有待合并数据的总存储量。如果该存储量超过
`min_merge_bytes_to_use_direct_io` 字节，ClickHouse 就会通过直接 I/O
接口 (`O_DIRECT` 选项) 从存储磁盘读取和写入数据。如果 `min_merge_bytes_to_use_direct_io = 0`，则会禁用直接 I/O。

## min\_partition\_age\_to\_force\_merge\_seconds

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.9"},{"label": "0"},{"label": "新增设置，用于强制合并不再接收插入的分区中的 分片"}]}]} />

如果某个分区中的每个 分片 都比该值更旧 (即该分区不再接收插入) ，则合并该分区中的 分片。与
`min_age_to_force_merge_seconds` 搭配 `min_age_to_force_merge_on_partition_only`
不同的是，该分区无需能在单次合并中处理完：每次合并仍会遵循
`max_bytes_to_merge_at_max_space_in_pool`。适用于 Simple 和
StochasticSimple 合并选择器。

此处比较的年龄是分区中最新 分片 的年龄
(`now - modification_time`，在其各个 分片 中取最小值) ，因此只有当每个 分片 的年龄都超过该值后，该规则才会生效。任何新的 分片 都会将其重置：插入、
变更，以及该设置本身所分配的每次合并，因为合并产生的
分片 也是新的。因此，一旦某次强制合并完成，强制机制便会解除，只有在再次经过该值所指定的时长且期间没有产生新 分片 后才会重新生效；所以需要多次合并的分区会在以该
时间间隔为间隔的若干轮次中逐步压缩，而不是在一次连续过程中完成。

强制机制的工作方式与 `min_age_to_force_merge_seconds` 完全相同：它会免除通常用于阻止分配不均衡合并的
大小比率要求，同时也会免除 `min_parts_to_merge_at_once` 下限，因此一次
强制合并可以覆盖少于该下限所要求数量的 分片。其他
启发式规则不会被关闭：`merge_selector_window_size` 仍会限定哪些 分片
会被检查，而 `merge_selector_enable_heuristic_to_remove_small_parts_at_right`
仍会从选定的包含三个或更多 分片 的范围中裁剪掉尾随的小 分片。
如果某个 workload 需要关闭其中任意一项，必须通过其各自的设置显式关闭。

在 Simple 和 StochasticSimple 合并选择器下，本设置不能与
`min_age_to_force_merge_seconds` 及
`min_age_to_force_merge_on_partition_only` 组合使用。该组合会一次性合并整个分区，
并且只有这种合并才会被标记为 final，而这正是 `ReplacingMergeTree`
得以执行 `CLEANUP` 的前提；按分区年龄强制执行常规合并会抢先将其打断。
对于能在单次合并中处理完的分区请使用该组合，对于无法如此处理的分区请使用本设置。其他选择器会忽略本设置，因此与它们组合使用是允许的。

可能的值：

* 正整数。

## min\_parts\_to\_merge\_at\_once

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

合并选择器一次可选中进行合并的最少数据分区片段数
(属于专家级设置；如果你不了解其作用，请不要更改) 。
0 - 已禁用。适用于 Simple 和 StochasticSimple 合并选择器。

## min\_replicated\_logs\_to\_keep

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

即使这些记录已过时，也会在 ZooKeeper 日志中保留大约这么多条最新记录。它不会影响表的运行：仅用于在清理前诊断 ZooKeeper 日志。

可能的值：

* 任何正整数。
