SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. ClickHouse
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

ClickHouse cheatsheet

Client and HTTP

CommandDescription
clickhouse-clientInteractive SQL shell (port 9000)
clickhouse-client -q 'SELECT 1'Run single query
clickhouse-client -h host -u user --passwordConnect to remote server
curl 'http://127.0.0.1:8123/ping'HTTP health check
curl 'http://127.0.0.1:8123/?query=SELECT+1'HTTP query

Service and logs

CommandDescription
systemctl status clickhouse-serverService status
systemctl restart clickhouse-serverRestart server
tail -f /var/log/clickhouse-server/clickhouse-server.logFollow server log
ss -tlnp | grep -E '8123|9000'Check listeners

Schema inspection

QueryDescription
SHOW DATABASESList databases
SHOW TABLES FROM dbList tables
DESCRIBE TABLE db.tableColumn definitions
SHOW CREATE TABLE db.tableDDL statement

System table queries

-- Parts and size per table SELECT database, table, count() AS parts, sum(bytes_on_disk) AS bytes FROM system.parts WHERE active GROUP BY database, table ORDER BY bytes DESC; -- Running queries SELECT query_id, user, elapsed, memory_usage, query FROM system.processes; -- Recent slow queries SELECT type, query_duration_ms, memory_usage, query FROM system.query_log WHERE event_time > now() - INTERVAL 1 HOUR AND type = 'QueryFinish' ORDER BY query_duration_ms DESC LIMIT 10; -- Replication status SELECT database, table, is_readonly, queue_size, absolute_delay FROM system.replicas;

Operational commands

Query / commandDescription
KILL QUERY WHERE query_id = '...'Cancel a running query
OPTIMIZE TABLE db.table FINALForce merge (use carefully)
SYSTEM FLUSH LOGSFlush log tables to disk
du -sh /var/lib/clickhouse/*Disk usage by database

Pro tips

  • Check system.parts when inserts slow down — too many parts is a common cause
  • Use system.processes to find queries consuming memory before OOM kills
  • Batch inserts (thousands of rows per INSERT) — avoid one-row inserts at high rate
  • Read the server log for "Memory limit exceeded" and "Too many parts" messages

Practice scenarios

Hands-on ClickHouse scenarios on live Linux VMs: clickhouse

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a