Skip to content

Instantly share code, notes, and snippets.

@masroorhasan
Created February 18, 2021 17:17
Show Gist options
  • Save masroorhasan/e96896f94427286552de361a9388a259 to your computer and use it in GitHub Desktop.
Save masroorhasan/e96896f94427286552de361a9388a259 to your computer and use it in GitHub Desktop.
SELECT
parts.*,
columns.compressed_size,
columns.uncompressed_size
FROM
(
SELECT
table,
formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size,
formatReadableSize(sum(data_compressed_bytes)) AS compressed_size
FROM system.columns
WHERE database = currentDatabase()
GROUP BY table
) AS columns
RIGHT JOIN
(
SELECT
table,
any(engine) AS engine
FROM system.parts
WHERE active AND (database = currentDatabase())
GROUP BY
database,
table
) AS parts ON columns.table = parts.table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment