Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created October 17, 2023 19:56
Show Gist options
  • Save tom-clickhouse/1435eba5e76701bee00a9145f40aec79 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/1435eba5e76701bee00a9145f40aec79 to your computer and use it in GitHub Desktop.
WITH
'pypi' AS db_name,
'pypi' AS table_name,
(
SELECT uuid
FROM system.tables
WHERE (database = db_name) AND (name = table_name)
) AS table_id
SELECT
DENSE_RANK() OVER(ORDER BY hostName()) AS n,
formatReadableQuantity(countIf(event_type = 'NewPart')) AS parts,
formatReadableQuantity(sumIf(rows, event_type = 'NewPart')) AS rows_total
FROM clusterAllReplicas(default, system.part_log)
WHERE table_uuid = table_id
GROUP BY hostName() WITH Totals
ORDER BY n
SETTINGS skip_unavailable_shards = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment