Created
October 18, 2023 06:39
-
-
Save tom-clickhouse/5c17431de8716041e10acde1ef379a8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
'default' AS db_name, | |
'pypi' AS table_name, | |
( | |
SELECT event_time | |
FROM clusterAllReplicas(default, system.query_log) | |
WHERE | |
has(tables, db_name || '.' || table_name) | |
AND length(tables) = 1 | |
AND is_initial_query | |
AND query_kind = 'Insert' | |
AND type = 'QueryFinish' | |
ORDER BY event_time_microseconds DESC | |
LIMIT 1 | |
) AS query_end_time | |
SELECT | |
max(event_time) as _event_time, | |
argMax(value, event_time) as parts | |
FROM clusterAllReplicas(default, system.asynchronous_metric_log) | |
WHERE | |
toStartOfInterval(event_time, toIntervalSecond(60)) = toStartOfInterval(query_end_time, toIntervalSecond(60)) | |
AND metric = 'MaxPartCountForPartition' | |
SETTINGS skip_unavailable_shards = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment