| name | clickhouse-cost-tuning |
| description | Optimize ClickHouse Cloud costs — compute scaling, storage tiering, compression,
and query efficiency for lower bills.
Use when analyzing ClickHouse Cloud bills, reducing storage costs,
or optimizing compute utilization.
Trigger: "clickhouse cost", "clickhouse billing", "reduce clickhouse spend",
"clickhouse pricing", "clickhouse expensive", "clickhouse storage cost".
|
| allowed-tools | Read, Grep |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","database","analytics","clickhouse","olap"] |
| compatible-with | claude-code |
ClickHouse Cost Tuning
Overview
Reduce ClickHouse Cloud costs through storage optimization, compression tuning,
TTL policies, compute scaling, and query efficiency improvements.
Prerequisites
- ClickHouse Cloud account with billing access
- Understanding of current data volumes and query patterns
Instructions
Step 1: Understand ClickHouse Cloud Pricing
| Component | Pricing Model | Key Driver |
|---|
| Compute | Per-hour per replica | vCPU + memory tier |
| Storage | Per GB-month | Compressed data on disk |
| Network | Per GB egress | Query result sizes |
| Backups | Per GB stored | Backup retention |
Key insight: ClickHouse bills on compressed storage, and ClickHouse
compresses extremely well (often 10-20x). Your cost driver is usually compute,
not storage.
Step 2: Analyze Storage Usage
SELECT
database,
table,
formatReadableSize(sum(bytes_on_disk)) AS compressed_size,
formatReadableSize(sum(data_uncompressed_bytes)) AS raw_size,
round(sum(data_uncompressed_bytes) / sum(bytes_on_disk), 1) AS compression_ratio,
sum(rows) AS total_rows,
count() AS parts
FROM system.parts
WHERE active
GROUP BY database, table
ORDER BY sum(bytes_on_disk) DESC;
,
,
type,
formatReadableSize((column_data_compressed_bytes)) compressed,
formatReadableSize((column_data_uncompressed_bytes)) raw,
round((column_data_uncompressed_bytes) (column_data_compressed_bytes), ) ratio
system.parts_columns
active database
, , type
(column_data_compressed_bytes)
LIMIT ;