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

> max_partitions_* グループに含まれる 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_partitions_per_insert_block">
  ## max\_partitions\_per\_insert\_block
</div>

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

1 つの挿入ブロックに含められるパーティションの最大数を制限します。
ブロック内のパーティション数が多すぎる場合は、例外がスローされます。

* 正の整数。
* `0` — パーティション数は無制限です。

**詳細**

データの挿入時に、ClickHouse は
挿入ブロック内のパーティション数を計算します。パーティション数が
`max_partitions_per_insert_block` を超える場合、
ClickHouse は `throw_on_max_partitions_per_insert_block` の設定に応じて警告をログに記録するか、
例外をスローします。例外メッセージは次のとおりです。

> "単一の INSERT ブロックに対してパーティション数が多すぎます (`partitions_count` 個のパーティション、上限は " + toString(max\_partitions) + ") 。
> この上限は 'max\_partitions\_per\_insert\_block' 設定で制御されます。
> 大量のパーティションを使用するのは、よくある誤解です。これにより、
> server の起動や INSERT クエリ、
> SELECT クエリが遅くなるなど、深刻なパフォーマンス低下を招きます。
> table 全体のパーティション総数は 1000..10000 未満に抑えることが推奨されます。なお、
> パーティション化は SELECT クエリを高速化するためのものではありません
> (範囲クエリを高速化するには ORDER BY key で十分です) 。
> パーティションはデータ操作 (DROP PARTITION など) のためのものです。"

<Note>
  この設定は安全しきい値です。大量のパーティションを使用するのは、よくある誤解であるためです。
</Note>

<div id="max_partitions_to_read">
  ## max\_partitions\_to\_read
</div>

<SettingsInfoBlock type="Int64" default_value="-1" />

1 つのクエリでアクセスできるパーティションの最大数を制限します。

テーブル作成時に指定した設定値は、クエリレベルの設定で上書きできます。

設定可能な値:

* 正の整数
* `-1` - 無制限 (デフォルト)

<Note>
  MergeTree 設定 [`max_partitions_to_read`](/ja/reference/settings/session-settings/max-partitions#max_partitions_to_read) は、テーブル設定でも指定できます。
</Note>
