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

# distributed_background_* 会话设置

> ClickHouse 在 distributed_background_* 自动生成分组中的会话设置。

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.settings](/docs/zh/reference/system-tables/settings) 中查看，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="distributed_background_insert_batch">
  ## distributed\_background\_insert\_batch
</div>

**别名**: `distributed_directory_monitor_batch_inserts`

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

启用/禁用按批次发送已插入的数据。

启用批次发送后，[Distributed](/docs/zh/reference/engines/table-engines/special/distributed) 表引擎会尝试在一次操作中发送多个包含已插入数据的文件，而不是分别发送。批次发送能更充分地利用服务器和网络资源，从而提升集群性能。

可能的值：

* 1 — 已启用。
* 0 — 已禁用。

<div id="distributed_background_insert_max_sleep_time_ms">
  ## distributed\_background\_insert\_max\_sleep\_time\_ms
</div>

**别名**：`distributed_directory_monitor_max_sleep_time_ms`

<SettingsInfoBlock type="毫秒" default_value="30000" />

[Distributed](/docs/zh/reference/engines/table-engines/special/distributed) 表引擎发送数据的最大时间间隔。用于限制 [distributed\_background\_insert\_sleep\_time\_ms](/docs/zh/reference/settings/session-settings/distributed-background#distributed_background_insert_sleep_time_ms) 设置中指定时间间隔的指数级增长。

可能的值：

* 以毫秒为单位的正整数。

<div id="distributed_background_insert_sleep_time_ms">
  ## distributed\_background\_insert\_sleep\_time\_ms
</div>

**别名**: `distributed_directory_monitor_sleep_time_ms`

<SettingsInfoBlock type="毫秒" default_value="100" />

[Distributed](/docs/zh/reference/engines/table-engines/special/distributed) 表引擎发送数据时使用的基础时间间隔。发生错误时，实际时间间隔会按指数级增长。

可能的值：

* 以毫秒为单位的正整数。

<div id="distributed_background_insert_split_batch_on_failure">
  ## distributed\_background\_insert\_split\_batch\_on\_failure
</div>

**别名**: `distributed_directory_monitor_split_batch_on_failure`

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

启用/禁用在失败时拆分批次。

有时，向远程分片发送某个特定批次可能会失败，这是因为后续存在复杂的管道处理 (例如带有 `GROUP BY` 的 `MATERIALIZED VIEW`) ，从而导致 `Memory limit exceeded` 或类似错误。在这种情况下，重试并不能解决问题 (而且还会导致该表的分布式发送卡住) ；但如果将该批次中的文件逐个发送，则可能成功执行 INSERT。

因此，将此设置设为 `1` 后，将对这类批次禁用批处理 (即临时对失败批次禁用 `distributed_background_insert_batch`) 。

可能的值：

* 1 — 启用。
* 0 — 禁用。

<Note>
  此设置也会影响损坏的批次 (这类批次可能是由于服务器 (机器) 异常终止，以及 [Distributed](/docs/zh/reference/engines/table-engines/special/distributed) 表引擎未使用 `fsync_after_insert`/`fsync_directories` 而产生的) 。
</Note>

<Note>
  不应依赖自动批次拆分，因为这可能会影响性能。
</Note>

<div id="distributed_background_insert_timeout">
  ## distributed\_background\_insert\_timeout
</div>

**别名**: `insert_distributed_timeout`

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

向 Distributed 表执行插入查询的超时时间。此设置仅在启用 insert\_distributed\_sync 时生效。值为 0 表示不设超时。
