> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-postgresql-tls-support.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# max_streams_* セッション設定

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

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

<div id="max_streams_for_files_processing_in_cluster_functions">
  ## max\_streams\_for\_files\_processing\_in\_cluster\_functions
</div>

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

0 以外の場合、\*Cluster table functions でファイルからデータを読み取るスレッド数を制限します。

<div id="max_streams_for_merge_tree_reading">
  ## max\_streams\_for\_merge\_tree\_reading
</div>

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

0 以外の場合、MergeTree テーブルの読み取りストリーム数を制限します。

<div id="max_streams_for_union_step">
  ## max\_streams\_for\_union\_step
</div>

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

`UNION` ステップで同時にアクティブになるデータストリーム数を制限します (`UNION DISTINCT` は `UNION ALL` ステップの後に `DISTINCT` ステップを適用して実装されているため、`UNION ALL` と `UNION DISTINCT` の両方に適用されます) 。`UNION` クエリに多数のサブクエリがある場合、それらはすべて同時に読み取りバッファを開くため、メモリ使用量はサブクエリ数に比例して増加します。この設定では `Concat` プロセッサを挿入してパイプラインを絞り込み、同時にアクティブなストリーム数がこの値を超えないようにすることで、ピークメモリを大幅に削減します。実際の制限値は、この値と `max_threads * max_streams_for_union_step_to_max_threads_ratio` の小さい方です (どちらか一方が 0 の場合は無視されます) 。両方が 0 の場合、絞り込みは適用されません。また、クエリプラン上、`UNION` の各出力ストリームを個別にソート済みの状態で維持する必要がある場合 (たとえば、read-in-order 最適化が `UNION` 全体に適用される場合) 、この制限は適用されません。その場合は順序の正しさが優先され、絞り込みはスキップされます。

<div id="max_streams_for_union_step_to_max_threads_ratio">
  ## max\_streams\_for\_union\_step\_to\_max\_threads\_ratio
</div>

<SettingsInfoBlock type="Float" default_value="8" />

この比率に `max_threads` を掛けた値によって、`UNION` ステップで同時にアクティブなストリーム数の上限が決まります (`UNION ALL` と `UNION DISTINCT` の両方に適用されます) 。実際の上限は、この計算値と `max_streams_for_union_step` のうち小さい方です (どちらか一方が 0 の場合は無視されます) 。たとえば、`max_threads = 8` でこの比率を 1 に設定すると、同時にアクティブになるストリームは最大 8 個です。この比率ベースの上限を無効にするには、0 に設定します。`max_streams_for_union_step` と同様に、クエリプラン上、`UNION` の各出力ストリームをそれぞれソート済みの状態に保つ必要がある場合、この上限は適用されません。

<div id="max_streams_multiplier_for_merge_tables">
  ## max\_streams\_multiplier\_for\_merge\_tables
</div>

<SettingsInfoBlock type="Float" default_value="5" />

Merge table から読み取る際に、より多くのストリームを要求します。ストリームは、Merge table が使用する各テーブルに分散されます。これにより、スレッド間で処理をより均等に分散でき、特に結合対象のテーブル間でサイズに差がある場合に効果的です。

<div id="max_streams_to_max_threads_ratio">
  ## max\_streams\_to\_max\_threads\_ratio
</div>

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

スレッド数を上回る数のソースを使用できるようにし、処理をスレッド間でより均等に分散できるようにします。将来的には、ソース数をスレッド数と同じにしつつ、各ソースが利用可能な処理を動的に自ら選択できるようになる見込みであるため、これは一時的な対策と想定されています。
