Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

max_execution_* session settings

These settings are available in system.settings and are autogenerated from source.

max_execution_speed

Type
UInt64
Default
0

The maximum number of execution rows per second. Checked on every data block when timeout_before_checking_execution_speed expires. If the execution speed is high, the execution speed will be reduced.

max_execution_speed_bytes

Type
UInt64
Default
0

The maximum number of execution bytes per second. Checked on every data block when timeout_before_checking_execution_speed expires. If the execution speed is high, the execution speed will be reduced.

max_execution_time

Type
Seconds
Default
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).

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.

max_execution_time_leaf

Type
Seconds
Default
0

Similar semantically to 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:

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:

SELECT count()
FROM cluster(cluster, view(SELECT * FROM t)) SETTINGS max_execution_time_leaf = 10;
Navigation