-
-
Save tom-clickhouse/05f40f98dbcc6b28be6de3f96668f37b 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, | |
'wikistat' AS table_name, | |
(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 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 insert_end_time | |
SELECT sum(CurrentMetric_Merge) AS merges | |
FROM clusterAllReplicas(default, system.metric_log) | |
WHERE event_time >= start_time AND event_time <= insert_end_time | |
SETTINGS skip_unavailable_shards = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment