Skip to content

Choose and verify a query thread limit ​

Use the documented max_threads setting when tuning the ceiling for an eligible query. It is not a command to resize an arbitrary server-wide thread pool, and it does not make every statement run in parallel.

sql
SELECT name, value, "default"
FROM system.settings
WHERE name = 'max_threads';

Zero selects the available hardware count capped at eight total query threads. An explicit value is from 0 through 64 and is also bounded by hardware, the XML ceiling and available workers. One requests serial execution.

sql
SET max_threads = 4;

The server persists this selected-database value for later requests. SET requires autocommit and no active transactions in that database. Use a representative read workload to compare performance before retaining the change.

Observe peak_threads_usage in system.processes while the request is present. It includes the main query thread, so serial execution reports one. A lower observed count than the ceiling is not necessarily a fault. Check query shape, measured duration and memory along with the count; adding allowed threads is not an automatic improvement.

See max_threads, active requests and server ceilings.