Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

max_memory_usage_* session settings

These settings are available in system.settings and are autogenerated from source.

max_memory_usage

Type
UInt64
Default
0

Cloud default value: depends on the amount of RAM on the replica.

The maximum amount of RAM to use for running a query on a single server. A value of 0 means unlimited.

This 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. Peak memory consumption is tracked for each query and written to the log.

Memory usage is not fully tracked for states of the following aggregate functions from String and Array arguments:

  • min
  • max
  • any
  • anyLast
  • argMin
  • argMax

Memory consumption is also restricted by the parameters max_memory_usage_for_user and max_server_memory_usage.

max_memory_usage_for_user

Type
UInt64
Default
0

The maximum amount of RAM to use for running a user’s queries on a single server. Zero means unlimited.

By default, the amount is not restricted (max_memory_usage_for_user = 0).

Also see the description of max_memory_usage.

For example if you want to set max_memory_usage_for_user to 1000 bytes for a user named clickhouse_read, you can use the statement

ALTER USER clickhouse_read SETTINGS max_memory_usage_for_user = 1000;

You can verify it worked by logging out of your client, logging back in, then use the getSetting function:

SELECT getSetting('max_memory_usage_for_user');
Navigation