From b99ad367a8cde08377885884e151d7daae4e06ae Mon Sep 17 00:00:00 2001 From: filimonov <1549571+filimonov@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:58:01 +0200 Subject: [PATCH] Create remove_empty_partitions_from_rq.md --- .../remove_empty_partitions_from_rq.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 content/en/altinity-kb-useful-queries/remove_empty_partitions_from_rq.md diff --git a/content/en/altinity-kb-useful-queries/remove_empty_partitions_from_rq.md b/content/en/altinity-kb-useful-queries/remove_empty_partitions_from_rq.md new file mode 100644 index 0000000000..47ff72eba9 --- /dev/null +++ b/content/en/altinity-kb-useful-queries/remove_empty_partitions_from_rq.md @@ -0,0 +1,22 @@ +--- +title: "Removing tasks in the replication queue related to empty partitions" +linkTitle: "Removing tasks in the replication queue related to empty partitions" +weight: 100 +description: >- + Removing tasks in the replication queue related to empty partitions +--- + +## Removing tasks in the replication queue related to empty partitions + +``` +SELECT 'ALTER TABLE ' || database || '.' || table || ' DROP PARTITION ID \''|| partition_id || '\';' FROM +(SELECT DISTINCT database, table, extract(new_part_name, '^[^_]+') as partition_id FROM clusterAllReplicas('{cluster}', system.replication_queue) ) as rq +LEFT JOIN +(SELECT database, table, partition_id, sum(rows) as rows_count, count() as part_count +FROM clusterAllReplicas('{cluster}', system.parts) +WHERE active GROUP BY database, table, partition_id +) as p +USING (database, table, partition_id) +WHERE p.rows_count = 0 AND p.part_count = 0 +FORMAT TSVRaw; +```