How to Check Table Size in ClickHouse

Galaxy Glossary

How do I check the size of a table in ClickHouse?

Use System tables or SHOW commands to calculate disk space occupied by a ClickHouse table.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Why check table size in ClickHouse?

Understand storage usage, forecast hardware needs, and spot abnormal growth early. Table-level size metrics help you plan TTL policies and shard placement.

Which system tables store size information?

system.parts (per part, per replica) and system.tables (aggregated per table) hold the byte counts you need. They update after each merge.

What is the simplest query?

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.

How do I check size of every table?

Aggregate bytes for each table in system.tables. Order by size desc to see heavy hitters quickly.

How can I convert bytes to human-readable units?

Use ClickHouse functions formatReadableSize() or divide by 1024³ for GB. Presenting sizes clearly speeds decision making.

How to monitor table size over time?

Schedule the size query in your observability stack and persist results to a metrics table. A simple cron + INSERT pattern is sufficient.

Best practice: include active and detached parts

Filter active in (1,0) to capture detached parts that still consume disk. Ignore only parts where remove_time > 0.

Best practice: account for compressed data

bytes_on_disk is after compression. If you need raw size, multiply by compression_ratio from system.parts.

Why How to Check Table Size in ClickHouse is important

How to Check Table Size in ClickHouse Example Usage


-- Size of Orders table and its partitions in GB
SELECT
    partition,
    formatReadableSize(sum(bytes_on_disk)) AS part_size,
    count() AS parts
FROM system.parts
WHERE database = 'ecommerce'
  AND table = 'Orders'
GROUP BY partition
ORDER BY sum(bytes_on_disk) DESC;

How to Check Table Size in ClickHouse Syntax


-- Per-table size in bytes
SELECT sum(bytes_on_disk) AS table_bytes
FROM system.parts
WHERE database = 'ecommerce'
  AND table = 'Orders'
  AND active = 1;

-- All tables ordered by size
SELECT
    database,
    table,
    formatReadableSize(sum(bytes_on_disk)) AS table_size
FROM system.parts
WHERE database = 'ecommerce'
GROUP BY database, table
ORDER BY sum(bytes_on_disk) DESC;

-- SHOW SIZE style helper (ClickHouse ≥23.3)
SHOW TABLES SIZE FROM ecommerce;

Common Mistakes

Frequently Asked Questions (FAQs)

Does SHOW TABLES SIZE work on older clusters?

No. The command was added in v23.3. For earlier versions query system.parts or system.tables manually.

Is bytes_on_disk replicated or local?

system.parts reports the size local to the node you query. Sum across replicas for total cluster usage.

Can I see column-level size?

Yes. Use system.parts_columns and aggregate data_compressed_bytes per column.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.