Skip to content

Set a query execution deadline ​

max_execution_time limits elapsed SQL processing time for one request. Its value is a finite nonnegative number of seconds; fractional seconds are accepted. A zero database value adds no database deadline, while a nonzero server ceiling still applies.

sql
SET max_execution_time = 2.5;

Send the setting as an administration request, then issue the workload in a later request. Settings are sampled at request start, so changing the value inside a batch does not retroactively change that batch's deadline.

Check the effective value ​

sql
SELECT name, value
FROM system.settings
WHERE name = 'max_execution_time'
FORMAT csv;

SET persists for the selected database and can affect other clients. It requires autocommit and no active transactions in that database. A saved value cannot relax a stricter XML ceiling.

Interpret a timeout ​

The deadline is checked cooperatively. A blocking operation can complete before a later check reports the time-limit error. Socket receive timeouts and an HTTP client's timeout govern different stages. A client timeout alone does not prove whether a write completed; reconcile its result before retrying.

See max_execution_time, HTTP requests and query history.