Search code examples
clickhouseclickhouse-client

Clickhouse Memory Issue


I am having a table with around 2 billion rows that i try to query the max(id) from. Id is not the sort key of the table and the table is using the table engine mergeTree.

No matter what I try, I get memory errors. This does not stop with this one query only. As soon as I try to query any table fully (vertical) to find data my 12 gb ram is not enough. Now I know I can just add more but that is not the point. Is it by design that clickhouse just throws an error when it doesn't have enough memory? Is there a setting that tells clickhouse to use disk instead?

SQL Error [241]: ClickHouse exception, code: 241, host: XXXXXX, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (for query) exceeded: would use 9.32 GiB (attempt to allocate chunk of 9440624 bytes), maximum: 9.31 GiB (version 21.4.6.55 (official build))


Solution

  • For me what worked was to change the maximum server memory usage from 0.9 to 1.2.

    <max_server_memory_usage_to_ram_ratio>1.2</max_server_memory_usage_to_ram_ratio> --> config.xml

    Thanks for the reply as it led me ultimately to this.