Skip to content

Instantly share code, notes, and snippets.

@kalkov
Last active September 27, 2022 08:21
Show Gist options
  • Save kalkov/e63fe1bfac2e72ccda22e1b7570a0978 to your computer and use it in GitHub Desktop.
Save kalkov/e63fe1bfac2e72ccda22e1b7570a0978 to your computer and use it in GitHub Desktop.
Handy Clickhouse queries
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
ORDER BY sum(bytes) DESC
SELECT
table,
formatReadableSize(sum(bytes)) AS size,
min(min_date) AS min_date,
max(max_date) AS max_date
FROM system.parts
WHERE active AND (table NOT LIKE '.inner%') AND (table NOT LIKE '_tmp%')
GROUP BY table
ORDER BY sum(bytes) DESC
SELECT database, table FROM system.tables where table like '%test%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment