Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created July 31, 2023 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom-clickhouse/1abb84d5da6a257e2879edd81e5278a6 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/1abb84d5da6a257e2879edd81e5278a6 to your computer and use it in GitHub Desktop.
WITH
'default' AS db_name,
'upclick_metrics' AS table_name,
10 AS interval_seconds,
(SELECT uuid FROM system.tables WHERE database = db_name and name = table_name) AS table_id,
(SELECT min(event_time) FROM system.part_log WHERE table_uuid = table_id) AS start_time
SELECT
toStartOfInterval(event_time, toIntervalSecond(interval_seconds)) AS t,
dateDiff('second', toStartOfInterval(start_time, toIntervalSecond(interval_seconds)), t) AS seconds,
max(value) as parts
FROM clusterAllReplicas(default, system.asynchronous_metric_log)
WHERE event_time >= start_time
AND metric = 'MaxPartCountForPartition'
GROUP BY t
ORDER BY t DESC
SETTINGS skip_unavailable_shards = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment