Show table sizes

Show disk usage of each table in a database, largest first

clickhouse-client -q "SELECT table, formatReadableSize(sum(bytes)) AS size FROM system.parts WHERE active AND database='mydb' GROUP BY table ORDER BY sum(bytes) DESC"

tool
clickhouse17 commands
tags
clickhousemonitoring

More clickhouse commands

  • clickhouse-client -q 'SELECT query_id, user, elapsed, query FROM system.processes ORDER BY elapsed DESC'

    List all running queries with elapsed time, longest first

  • clickhouse-client -q "KILL QUERY WHERE query_id='<id>'"

    Stop a long-running or stuck query

  • clickhouse-client -q 'SYSTEM DROP MARK CACHE; SYSTEM DROP UNCOMPRESSED CACHE'

    Drop the mark cache and the uncompressed cache to free memory

  • clickhouse-client -q 'SYSTEM SYNC REPLICA mydb.myTable'

    Wait until the replica catches up with its replication queue in ZooKeeper

  • clickhouse-client --host ch.example.com --user default --password secret -q 'SELECT version()'

    Run a single query with clickhouse-client and exit

all 17 clickhouse commands