> ## 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_* session settings

> ClickHouse session settings in the max_execution_* generated group.

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
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.settings](/docs/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="max_execution_speed">
  max\_execution\_speed
</h2>

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

The maximum number of execution rows per second. Checked on every data block when
[`timeout_before_checking_execution_speed`](/docs/reference/settings/session-settings/other#timeout_before_checking_execution_speed)
expires. If the execution speed is high, the execution speed will be reduced.

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

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

The maximum number of execution bytes per second. Checked on every data block when
[`timeout_before_checking_execution_speed`](/docs/reference/settings/session-settings/other#timeout_before_checking_execution_speed)
expires. If the execution speed is high, the execution speed will be reduced.

<h2 id="max_execution_time">
  max\_execution\_time
</h2>

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

The maximum query execution time in seconds.

The `max_execution_time` parameter can be a bit tricky to understand.
It operates based on interpolation relative to the current query execution speed
(this behaviour is controlled by [`timeout_before_checking_execution_speed`](/docs/reference/settings/session-settings/other#timeout_before_checking_execution_speed)).

ClickHouse will interrupt a query if the projected execution time exceeds the
specified `max_execution_time`. By default, the `timeout_before_checking_execution_speed`
is set to 10 seconds. This means that after 10 seconds of query execution, ClickHouse
will begin estimating the total execution time. If, for example, `max_execution_time`
is set to 3600 seconds (1 hour), ClickHouse will terminate the query if the estimated
time exceeds this 3600-second limit. If you set `timeout_before_checking_execution_speed`
to 0, ClickHouse will use the clock time as the basis for `max_execution_time`.

If query runtime exceeds the specified number of seconds, the behavior will be
determined by the 'timeout\_overflow\_mode', which by default is set to `throw`.

<Note>
  The timeout is checked and the query can stop only in designated places during data processing.
  It currently cannot stop during merging of aggregation states or during query analysis,
  and the actual run time will be higher than the value of this setting.
</Note>

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

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

Similar semantically to [`max_execution_time`](/docs/reference/settings/session-settings/max-execution#max_execution_time) but only
applied on leaf nodes for distributed or remote queries.

For example, if we want to limit the execution time on a leaf node to `10s` but
have no limit on the initial node, instead of having `max_execution_time` in the
nested subquery settings:

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

We can use `max_execution_time_leaf` as the query settings:

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