Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techkuz/8d1cd7682b7a1e29b753e42ba18ab01a to your computer and use it in GitHub Desktop.
Save techkuz/8d1cd7682b7a1e29b753e42ba18ab01a to your computer and use it in GitHub Desktop.
clickhouse get tables size
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@techkuz
Copy link
Author

techkuz commented Oct 2, 2018

More detailed with rows count and average day size

SELECT table, formatReadableSize(size) as size, rows, days, formatReadableSize(avgDaySize) as avgDaySize FROM (
    SELECT
        table,
        sum(bytes) AS size,
        sum(rows) AS rows,
        min(min_date) AS min_date,
        max(max_date) AS max_date,
        (max_date - min_date) AS days,
        size / (max_date - min_date) AS avgDaySize
    FROM system.parts
    WHERE active
    GROUP BY table
    ORDER BY rows DESC
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment