ClickHouse Memory Configuration Settings
max_server_memory_usage
Limits total RAM usage by the ClickHouse server.
Possible values:
- Positive integer.
- 0 — Auto.
Default value: 0.
Additional Info
The default max_server_memory_usage value is calculated as memory_amount * max_server_memory_usage_to_ram_ratio.
max_server_memory_usage_to_ram_ratio
Defines the fraction of the total physical RAM amount, available to the ClickHouse server. If the server tries to utilize more, the memory is cut down to the appropriate amount.
Possible values:
- Positive double.
- 0 — The ClickHouse server can use all available RAM.
Default value: 0.9.
Usage
On hosts with low RAM and swap, you possibly need to set max_server_memory_usage_to_ram_ratio larger than 1.
<max_server_memory_usage_to_ram_ratio>0.9</max_server_memory_usage_to_ram_ratio>
max_memory_usage
The maximum amount of RAM to use for running a query on a single server.
In the default configuration file, the maximum is 10 GB.
The setting does not consider the volume of available memory or the total volume of memory on the machine. The restriction applies to a single query within a single server. You can use SHOW PROCESSLIST to see the current memory consumption for each query. Besides, the peak memory consumption is tracked for each query and written to the log.
Memory usage is not monitored for the states of certain aggregate functions.
Memory usage is not fully tracked for states of the aggregate functions min, max, any, anyLast, argMin, argMax from String and Array arguments.
Memory consumption is also restricted by the parameters max_memory_usage_for_userand max_server_memory_usage.
max_concurrent_queries
The maximum number of simultaneously processed queries.
Note that other limits also apply: max_concurrent_insert_queries, max_concurrent_select_queries, max_concurrent_queries_for_user, max_concurrent_queries_for_all_users.
Possible values:
- Positive integer.
- 0 — No limit.
Default value: 100.
Example:
<max_concurrent_queries>200</max_concurrent_queries>
Note: These settings can be modified at runtime and will take effect immediately. Queries that are already running will remain unchanged.
max_concurrent_insert_queries
The maximum number of simultaneously processed INSERT queries.
Possible values:
- Positive integer.
- 0 — No limit.
Default value: 0.
Example
<max_concurrent_insert_queries>100</max_concurrent_insert_queries>
Note: These settings can be modified at runtime and will take effect immediately. Queries that are already running will remain unchanged.
max_concurrent_select_queries
The maximum number of simultaneously processed SELECT queries.
Possible values:
- Positive integer.
- 0 — No limit.
Default value: 0.
Example
<max_concurrent_select_queries>100</max_concurrent_select_queries>
Note: These settings can be modified at runtime and will take effect immediately. Queries that are already running will remain unchanged.
max_concurrent_queries_for_user
The maximum number of simultaneously processed queries related to MergeTree table per user.
Possible values:
- Positive integer.
- 0 — No limit.
Default value: 0.
Example
<max_concurrent_queries_for_user>5</max_concurrent_queries_for_user>
max_concurrent_queries_for_all_users
Throw exception if the value of this setting is less or equal than the current number of simultaneously processed queries.
Example: max_concurrent_queries_for_all_users can be set to 99 for all users and database administrator can set it to 100 for itself to run queries for investigation even when the server is overloaded.
Modifying the setting for one query or user does not affect other queries.
Possible values:
- Positive integer.
- 0 — No limit.
Default value: 0.
Example:
<max_concurrent_queries_for_all_users>99</max_concurrent_queries_for_all_users>
max_memory_usage_for_user
The maximum amount of RAM to use for running a user’s queries on a single server.
Default values are defined in Settings.h. By default, the amount is not restricted (max_memory_usage_for_user = 0).