Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Created January 5, 2025 22:56
Show Gist options
  • Save nicksherron/8b3363a7df9547283d80dbe7adb65683 to your computer and use it in GitHub Desktop.
Save nicksherron/8b3363a7df9547283d80dbe7adb65683 to your computer and use it in GitHub Desktop.
SELECT
l.* EXCEPT(total_compressed_bytes, data_compressed_bytes),
formatReadableSize(total_compressed_bytes) as total_comp
FROM (
SELECT
name,
type,
data_compressed_bytes,
sum(data_compressed_bytes) OVER (ORDER BY data_compressed_bytes DESC) AS total_compressed_bytes,
formatReadableSize(data_compressed_bytes) as comp,
formatReadableSize(data_uncompressed_bytes) as uncomp,
-- use xxx and xx to show if is_in_partition_key, is_in_sorting_key, is_in_primary_key
-- is_in_partition_key,
-- is_in_sorting_key,
-- is_in_primary_key
case when is_in_partition_key and is_in_sorting_key and is_in_primary_key then 'xxx'
when is_in_sorting_key and is_in_primary_key then 'xx'
when is_in_primary_key then 'x'
else '' end as keys
FROM system.columns
WHERE `table` = 'logs'
ORDER BY data_compressed_bytes DESC
) l
Format PrettyCompactMonoBlock;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment