Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created August 27, 2023 15:10
Show Gist options
  • Save tom-clickhouse/f9c683945ea805062f7f5f63bf8b1389 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/f9c683945ea805062f7f5f63bf8b1389 to your computer and use it in GitHub Desktop.
WITH
'default' AS db_name,
'wikistat' 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