max_result_rows and max_response_bytes
These UInt64 settings limit successful request results. Both default to 0, leaving no additional database ceiling.
Limits
- max_result_rows counts returned rows across the request's SELECT, SHOW, PRAGMA and RETURNING results.
- max_response_bytes counts the complete successful logical response, including formatted values, borders and protocol fields such as the status byte, database name and separator.
The protocol independently caps responses at 16 MiB. Error responses retain that fixed frame limit, so a small result budget can still return a diagnostic.
Scope and changes
Use SET after selecting a server database. The change is persisted for that database and observed by other clients before later requests. It requires autocommit and no active transactions in the database. Resource limits are sampled once per request; a SET within a batch changes defaults for later requests.
A nonzero XML ceiling can only be tightened by the saved database value. Zero removes the database's additional ceiling while retaining any server ceiling. Inspect system.settings for effective values and main.settings for stored values.
Write results
A RETURNING result that violates a result limit rolls back that statement's writes, including inside an explicit transaction. Earlier statements in a request retain their normal commit behavior. Transaction recovery commands and management controls remain available.
Example
SET max_result_rows = 1000;
SET max_response_bytes = 1048576;SELECT name, value
FROM system.settings
WHERE name IN ('max_result_rows', 'max_response_bytes')
ORDER BY name
FORMAT csv;"max_response_bytes","1048576"
"max_result_rows","1000"SQL LIMIT controls one query result. It does not replace the cumulative request limits described here.