To investigate high RAM usage in ClickHouse and determine what's consuming so much memory, you can try the following steps:
-
Check system tables: Query the system.metrics and system.asynchronous_metrics tables to get an overview of memory usage:
SELECT * FROM system.metrics WHERE metric LIKE '%Memory%'; SELECT * FROM system.asynchronous_metrics WHERE metric LIKE '%Memory%';
-
Examine query memory usage: Look at currently running queries and their memory consumption:
SELECT query_id, user, elapsed, memory_usage FROM system.processes ORDER BY memory_usage DESC;
-
Check table sizes: Identify large tables that might be causing memory pressure:
SELECT database, name, total_bytes, total_rows FROM system.tables ORDER BY total_bytes DESC LIMIT 10;
-
Review merge processes: Check if there are any large merges in progress:
SELECT * FROM system.merges;
-
Inspect background processes: Look at background processes that might be consuming memory:
SELECT * FROM system.background_processing_pool;