Created
March 6, 2026 07:27
-
-
Save lindesvard/7590a0ed04ebdcccc76447f88491dd45 to your computer and use it in GitHub Desktop.
Clickhouse table size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select parts.*, | |
| columns.compressed_size, | |
| columns.uncompressed_size, | |
| columns.compression_ratio, | |
| columns.compression_percentage | |
| from ( | |
| select table, | |
| formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, | |
| formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, | |
| round(sum(data_compressed_bytes) / sum(data_uncompressed_bytes), 3) AS compression_ratio, | |
| round((100 - (sum(data_compressed_bytes) * 100) / sum(data_uncompressed_bytes)), 3) AS compression_percentage | |
| from system.columns | |
| group by table | |
| ) columns | |
| right join ( | |
| select table, | |
| sum(rows) as rows, | |
| max(modification_time) as latest_modification, | |
| formatReadableSize(sum(bytes)) as disk_size, | |
| formatReadableSize(sum(primary_key_bytes_in_memory)) as primary_keys_size, | |
| any(engine) as engine, | |
| sum(bytes) as bytes_size | |
| from system.parts | |
| where active | |
| group by database, table | |
| ) parts on columns.table = parts.table | |
| order by parts.bytes_size desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment