Use System tables or SHOW commands to calculate disk space occupied by a ClickHouse table.
Understand storage usage, forecast hardware needs, and spot abnormal growth early. Table-level size metrics help you plan TTL policies and shard placement.
system.parts (per part, per replica) and system.tables (aggregated per table) hold the byte counts you need. They update after each merge.
Select sum(bytes_on_disk) from system.parts filtered by database and table. This returns the exact bytes currently on disk, including unmerged parts and projections.
Aggregate bytes for each table in system.tables. Order by size desc to see heavy hitters quickly.
Use ClickHouse functions formatReadableSize() or divide by 1024³ for GB. Presenting sizes clearly speeds decision making.
Schedule the size query in your observability stack and persist results to a metrics table. A simple cron + INSERT pattern is sufficient.
Filter active in (1,0) to capture detached parts that still consume disk. Ignore only parts where remove_time > 0.
bytes_on_disk is after compression. If you need raw size, multiply by compression_ratio from system.parts.
No. The command was added in v23.3. For earlier versions query system.parts or system.tables manually.
system.parts reports the size local to the node you query. Sum across replicas for total cluster usage.
Yes. Use system.parts_columns and aggregate data_compressed_bytes per column.