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

# max_execution_* セッション設定

> 自動生成された max_execution_* グループ内の 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="max_execution_speed">
  ## max\_execution\_speed
</div>

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

1 秒あたりの実行行数の上限です。各データブロックで
[`timeout_before_checking_execution_speed`](/docs/ja/reference/settings/session-settings/other#timeout_before_checking_execution_speed)
の期限が切れるたびにチェックされます。実行速度が高すぎる場合は、実行速度が抑制されます。

<div id="max_execution_speed_bytes">
  ## max\_execution\_speed\_bytes
</div>

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

1 秒あたりの実行バイト数の最大値です。各データブロックで
[`timeout_before_checking_execution_speed`](/docs/ja/reference/settings/session-settings/other#timeout_before_checking_execution_speed)
の期限が切れるたびにチェックされます。実行速度が高すぎる場合は、実行速度が抑制されます。

<div id="max_execution_time">
  ## max\_execution\_time
</div>

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

クエリ実行時間の最大値 (秒) です。

`max_execution_time` パラメータは、少しわかりにくい場合があります。
これは、現在のクエリ実行速度に対する補間に基づいて動作します
(この挙動は [`timeout_before_checking_execution_speed`](/docs/ja/reference/settings/session-settings/other#timeout_before_checking_execution_speed) で制御されます) 。

ClickHouse は、予測される実行時間が指定した
`max_execution_time` を超える場合、クエリを中断します。既定では、`timeout_before_checking_execution_speed`
は 10 秒に設定されています。つまり、クエリ実行開始から 10 秒経過すると、ClickHouse
は合計実行時間の推定を開始します。たとえば、`max_execution_time`
を 3600 秒 (1 時間) に設定した場合、推定時間がこの 3600 秒の上限を超えると、ClickHouse は
クエリを終了します。`timeout_before_checking_execution_speed`
を 0 に設定すると、ClickHouse は `max_execution_time` の基準として実際の経過時間を使用します。

クエリの実行時間が指定した秒数を超えた場合の動作は、
既定で `throw` に設定されている `timeout_overflow_mode` によって決まります。

<Note>
  タイムアウトの確認が行われ、クエリを停止できるのは、データ処理中の所定の箇所に限られます。
  現在のところ、集約状態のマージ中やクエリ解析中には停止できないため、
  実際の実行時間はこの設定値より長くなります。
</Note>

<div id="max_execution_time_leaf">
  ## max\_execution\_time\_leaf
</div>

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

[`max_execution_time`](/docs/ja/reference/settings/session-settings/max-execution#max_execution_time) と意味としては似ていますが、
分散クエリまたはリモートクエリのリーフノードにのみ適用されます。

たとえば、リーフノードでの実行時間を `10s` に制限しつつ、
初期ノードでは制限を設けたくない場合は、ネストされたサブクエリの設定に
`max_execution_time` を指定する代わりに、次のようにします:

```sql theme={null}
SELECT count()
FROM cluster(cluster, view(SELECT * FROM t SETTINGS max_execution_time = 10));
```

クエリ設定として `max_execution_time_leaf` を指定できます:

```sql theme={null}
SELECT count()
FROM cluster(cluster, view(SELECT * FROM t)) SETTINGS max_execution_time_leaf = 10;
```
