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

# parallel_* 会话设置

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

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>;
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <Icon />
                <span>Beta</span>
            </a>;
  }
  return <div className="betaBadge">
            <Icon />
            <span>
                Beta 版功能。 
                <u>
                    <a href="/docs/docs/beta-and-experimental-features#beta-features">
                        了解更多。
                    </a>
                </u>
            </span>
        </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中找到，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="parallel_distributed_insert_select">
  ## parallel\_distributed\_insert\_select
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.7"},{"label": "2"},{"label": "默认启用并行分布式 `INSERT ... SELECT`"}]}]} />

启用并行分布式 `INSERT ... SELECT` 查询。

如果执行 `INSERT INTO distributed_table_a SELECT ... FROM distributed_table_b` 查询，并且两张表使用同一个集群，且两张表要么都是 [复制表](/docs/zh/reference/engines/table-engines/mergetree-family/replication)，要么都是非复制表，那么该查询会在每个分片上本地处理。

可选值：

* `0` — 禁用。
* `1` — `SELECT` 将在每个分片上针对分布式引擎的底层表执行。
* `2` — `SELECT` 和 `INSERT` 都将在每个分片上针对分布式引擎的底层表执行。

从 v25.4 起，源表为 `ReplicatedMergeTree` 或 `SharedMergeTree` 的 `INSERT ... SELECT` 也可以在各副本间并行执行。要启用此功能：

* `parallel_distributed_insert_select = 2`
* `enable_parallel_replicas = 1`

<div id="parallel_hash_join_threshold">
  ## parallel\_hash\_join\_threshold
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.5"},{"label": "100000"},{"label": "新设置"}]}, {"id": "row-2","items": [{"label": "25.4"},{"label": "0"},{"label": "新设置"}]}, {"id": "row-3","items": [{"label": "25.3"},{"label": "0"},{"label": "新设置"}]}]} />

应用基于哈希的 JOIN 算法时，此阈值用于帮助决定使用 `hash` 还是 `parallel_hash` (仅在可以估算右表大小时适用) 。
如果已知右表大小低于该阈值，则使用前者。

<div id="parallel_non_joined_rows_processing">
  ## parallel\_non\_joined\_rows\_processing
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "1"},{"label": "新增设置：启用在 RIGHT/FULL `parallel_hash` JOIN 中并行处理右表未匹配的行。"}]}]} />

允许在 RIGHT 和 FULL JOIN 期间使用多个线程并行处理右表中未匹配的行。
使用 `parallel_hash` join 算法处理大表时，这可以加快未匹配阶段的处理速度。
禁用后，未匹配的行将由单个线程处理。

<div id="parallel_replica_offset">
  ## parallel\_replica\_offset
</div>

<BetaBadge />

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

这是一个内部设置，不应直接使用，表示“并行副本”模式的实现细节。对于分布式查询，发起服务器会自动将此设置设为参与并行副本查询处理的副本索引。

<div id="parallel_view_processing">
  ## parallel\_view\_processing
</div>

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

启用后，将并发而非按顺序向已附加的视图推送。
