<!-- Maximum memory usage (resident set size) for server process. Zero value or unset means default. Default is "max_server_memory_usage_to_ram_ratio" of available physical RAM. If the value is larger than "max_server_memory_usage_to_ram_ratio" of available physical RAM, it will be cut down.
The constraint is checked on query execution time. If a query tries to allocate memory and the current memory usage plus allocation is greater than specified threshold, exception will be thrown.
It is not practical to set this constraint to small values like just a few gigabytes, because memory allocator will keep this amount of memory in caches and the server will deny service of queries. --> <max_server_memory_usage>8G</max_server_memory_usage>
select * from `system`.settings where name in( 'max_memory_usage_for_user', 'max_memory_usage', 'max_bytes_before_external_group_by', 'max_bytes_before_external_sort', 'max_memory_usage_for_all_queries', 'max_concurrent_queries_for_user', 'max_concurrent_queries_for_all_users', 'max_concurrent_queries', 'max_server_memory_usage', 'max_server_memory_usage_to_ram_ratio', 'max_thread_pool_size', 'distributed_aggregation_memory_efficient' );
后来增加了配置项
config.xml
max_server_memory_usage_to_ram_ratio
这里按照总内存的百分比计算
1 2 3 4
<clickhouse> <!-- On memory constrained environments you may have to set this to value larger than 1.--> <max_server_memory_usage_to_ram_ratio>0.2</max_server_memory_usage_to_ram_ratio> </clickhouse>