Show running queries

Show the 10 longest-running queries right now

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

tool
clickhouse17 commands
tags
clickhousedebugmonitoring

More clickhouse commands

  • clickhouse-client -q "KILL QUERY WHERE query_id = 'abc-123'"

    Force-stop a query by its query_id

  • clickhouse-client -q 'SELECT database, table, formatReadableSize(sum(bytes_on_disk)) AS size FROM system.parts GROUP BY database, table ORDER BY sum(bytes_on_disk) DESC LIMIT 20'

    Show the top 20 tables by size on disk

  • clickhouse-client -q 'OPTIMIZE TABLE mydb.mytable FINAL'

    Force a merge of all parts, be careful with large tables

  • clickhouse-client --query 'INSERT INTO mydb.events FORMAT CSVWithNames' < events.csv

    Bulk-load a CSV file into a ClickHouse table

  • clickhouse-client -q 'SELECT database, table, is_leader, queue_size, absolute_delay FROM system.replicas WHERE absolute_delay > 0'

    Show replication lag for replicas that are behind

all 17 clickhouse commands