Skip to content

Instantly share code, notes, and snippets.

@samof76
Created September 14, 2024 03:47
Show Gist options
  • Save samof76/8744ab377cd1142960f4e37039966441 to your computer and use it in GitHub Desktop.
Save samof76/8744ab377cd1142960f4e37039966441 to your computer and use it in GitHub Desktop.
ClickHouse High Memory Usage

To investigate high RAM usage in ClickHouse and determine what's consuming so much memory, you can try the following steps:

  1. 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%';
  2. 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;
  3. 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;
  4. Review merge processes: Check if there are any large merges in progress:

    SELECT * FROM system.merges;
  5. Inspect background processes: Look at background processes that might be consuming memory:

    SELECT * FROM system.background_processing_pool;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment