Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save techkuz/8d1cd7682b7a1e29b753e42ba18ab01a to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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