-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create remove_empty_partitions_from_rq.md
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
content/en/altinity-kb-useful-queries/remove_empty_partitions_from_rq.md
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
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; | ||
``` |