Skip to content

Commit

Permalink
Create remove_empty_partitions_from_rq.md
Browse files Browse the repository at this point in the history
  • Loading branch information
filimonov authored Aug 9, 2023
1 parent 4d825a3 commit b99ad36
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
```

0 comments on commit b99ad36

Please sign in to comment.