> ## 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_* セッション設定

> distributed_* の生成グループに含まれる ClickHouse のセッション設定。

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/ja/reference/system-tables/settings) で確認でき、[ソースコード](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) から自動生成されています。

<div id="distributed_aggregation_memory_efficient">
  ## distributed\_aggregation\_memory\_efficient
</div>

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

分散集約の省メモリモードが有効かどうかを示します。

<div id="distributed_connections_pool_size">
  ## distributed\_connections\_pool\_size
</div>

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

単一の分散テーブルに対するすべてのクエリの分散処理で使用される、リモートサーバーへの同時接続の最大数です。値は、クラスター内のサーバー数以上に設定することを推奨します。

<div id="distributed_foreground_insert">
  ## distributed\_foreground\_insert
</div>

**別名**: `insert_distributed_sync`

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

[分散テーブル](/docs/ja/reference/engines/table-engines/special/distributed)へのデータの同期挿入を有効または無効にします。

デフォルトでは、分散テーブルにデータを挿入すると、ClickHouse サーバーはバックグラウンドモードでクラスター内のノードにデータを送信します。`distributed_foreground_insert=1` の場合、データは同期的に処理され、`INSERT` 操作が成功するのは、すべてのデータがすべての分片に保存された後のみです (`internal_replication` が true の場合は、各分片で少なくとも 1 つのレプリカ) 。

設定可能な値:

* `0` — データはバックグラウンドモードで挿入されます。
* `1` — データは同期モードで挿入されます。

Cloud でのデフォルト値: `1`.

**関連項目**

* [Distributed テーブルエンジン](/docs/ja/reference/engines/table-engines/special/distributed)
* [分散テーブルの管理](/docs/ja/reference/statements/system#managing-distributed-tables)

<div id="distributed_group_by_no_merge">
  ## distributed\_group\_by\_no\_merge
</div>

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

分散クエリ処理で、異なるサーバーからの集約状態をマージしません。異なる分片に異なるキーがあることが確実な場合に使用できます

設定可能な値:

* `0` — 無効 (最終的なクエリ処理はイニシエーター ノードで実行されます) 。
* `1` - 分散クエリ処理で、異なるサーバーからの集約状態をマージしません (クエリは分片上で完全に処理され、イニシエーターはデータをプロキシするだけです) 。異なる分片に異なるキーがあることが確実な場合に使用できます。
* `2` - `1` と同じですが、`ORDER BY` と `LIMIT` をイニシエーターで適用します (`distributed_group_by_no_merge=1` のようにクエリがリモート ノード上で完全に処理される場合は適用できません)  (`ORDER BY` や `LIMIT` を含むクエリで使用できます) 。

**例**

```sql theme={null}
SELECT *
FROM remote('127.0.0.{2,3}', system.one)
GROUP BY dummy
LIMIT 1
SETTINGS distributed_group_by_no_merge = 1
FORMAT PrettyCompactMonoBlock

┌─dummy─┐
│     0 │
│     0 │
└───────┘
```

```sql theme={null}
SELECT *
FROM remote('127.0.0.{2,3}', system.one)
GROUP BY dummy
LIMIT 1
SETTINGS distributed_group_by_no_merge = 2
FORMAT PrettyCompactMonoBlock

┌─dummy─┐
│     0 │
└───────┘
```

<div id="distributed_insert_skip_read_only_replicas">
  ## distributed\_insert\_skip\_read\_only\_replicas
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "0"},{"label": "true の場合、Distributed への INSERT 時に読み取り専用レプリカをスキップします"}]}]} />

Distributed への INSERT クエリで、読み取り専用レプリカをスキップする機能を有効にします。

設定可能な値:

* 0 — INSERT は通常どおり実行され、読み取り専用レプリカに送られた場合は失敗します
* 1 — イニシエーターは、データを分片に送信する前に読み取り専用レプリカをスキップします。

<div id="distributed_product_mode">
  ## distributed\_product\_mode
</div>

<SettingsInfoBlock type="DistributedProductMode" default_value="deny" />

[分散サブクエリ](/docs/ja/reference/statements/in)の動作を変更します。

ClickHouse は、クエリに分散テーブルの直積が含まれている場合、つまり分散テーブルに対するクエリに、その分散テーブルに対する非 GLOBAL のサブクエリが含まれている場合に、この設定を適用します。

制限事項:

* IN および JOIN サブクエリにのみ適用されます。
* FROM 句で、複数の分片を含む分散テーブルが使用されている場合に限ります。
* サブクエリの対象が、複数の分片を含む分散テーブルである場合に限ります。
* テーブル値 [remote](/docs/ja/reference/functions/table-functions/remote) 関数には使用されません。

設定可能な値:

* `deny` — デフォルト値。これらの種類のサブクエリの使用を禁止します ("Double-distributed in/JOIN subqueries is denied" 例外を返します) 。
* `local` — サブクエリ内のデータベースとテーブルを、宛先サーバー (分片) のローカルなものに置き換え、通常の `IN`/`JOIN` はそのままにします。
* `global` — `IN`/`JOIN` クエリを `GLOBAL IN`/`GLOBAL JOIN` に置き換えます。
* `allow` — これらの種類のサブクエリの使用を許可します。

<div id="distributed_push_down_limit">
  ## distributed\_push\_down\_limit
</div>

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

各分片ごとに [LIMIT](/docs/ja/reference/settings/session-settings/other#limit) を個別に適用するかどうかを有効または無効にします。

これにより、次のことを回避できます。

* 余分な行をネットワーク経由で送信すること。
* イニシエーターで LIMIT を超える行を処理すること。

バージョン 21.9 以降では、`distributed_push_down_limit` は少なくとも 1 つの条件が満たされる場合にのみクエリ実行を変更するため、結果が不正確になることはなくなりました。

* [distributed\_group\_by\_no\_merge](/docs/ja/reference/settings/session-settings/distributed#distributed_group_by_no_merge) > 0。
* クエリに `GROUP BY`/`DISTINCT`/`LIMIT BY` **がなく**、`ORDER BY`/`LIMIT` **がある**。
* クエリに `GROUP BY`/`DISTINCT`/`LIMIT BY` と `ORDER BY`/`LIMIT` **があり**、かつ:
  * [optimize\_skip\_unused\_shards](/docs/ja/reference/settings/session-settings/optimize-skip#optimize_skip_unused_shards) が有効になっている。
  * [optimize\_distributed\_group\_by\_sharding\_key](/docs/ja/reference/settings/session-settings/optimize#optimize_distributed_group_by_sharding_key) が有効になっている。

設定可能な値:

* 0 — 無効。
* 1 — 有効。

関連項目:

* [distributed\_group\_by\_no\_merge](/docs/ja/reference/settings/session-settings/distributed#distributed_group_by_no_merge)
* [optimize\_skip\_unused\_shards](/docs/ja/reference/settings/session-settings/optimize-skip#optimize_skip_unused_shards)
* [optimize\_distributed\_group\_by\_sharding\_key](/docs/ja/reference/settings/session-settings/optimize#optimize_distributed_group_by_sharding_key)
