ClickHouse pricing analysis means estimating storage, compute, and data-transfer costs by querying ClickHouse system tables or cloud billing exports.
ClickHouse Cloud charges mainly on three dimensions: compressed storage (GB-month), compute units (vCPU-hour), and egress traffic (GB). Self-hosted clusters add hardware, network, and support costs. Understanding which driver dominates lets you focus optimization efforts where they actually save money.
Query system.parts
to sum on-disk bytes for each table. Divide by 1 024³ to convert to GB, then multiply by the provider’s $/GB-month rate. Run the query on a schedule and store the results in a cost-tracking table so trends are visible.
The query in the next section scans only the ecommerce
database and groups by table to show granular usage, helping you spot oversized fact tables such as OrderItems
.
Cloud vendors expose per-hour pricing per service class. Multiply the number of CPU-seconds reported in system.query_log
by the hourly rate / 3 600. Roll up by day to catch workload spikes early and downsize before the next billing cycle.
Historical data queried rarely can live on cheaper object storage. Move partitions older than N months with ALTER TABLE … MOVE PARTITION
. This keeps hot storage light and reduces $/GB on the bill without sacrificing availability.
Compress columns with the CODEC(ZSTD, LZ4)
family, merge small parts regularly, and avoid SELECT *. Restrict materialized views to columns actually used in dashboards. Finally, delete raw JSON once it is parsed into typed columns.
For small to medium workloads, managed ClickHouse often costs less once you factor in maintenance hours. At petabyte scale, self-hosting with spot instances can be cheaper but needs ops expertise.
Daily snapshots strike a balance between granularity and overhead. Hourly tracking is helpful during migrations or major traffic events.