Skip to content

Commit c297f3c

Browse files
committed
Fixed but with cleanup retention query
1 parent 75f593c commit c297f3c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ServiceControl.Audit.Persistence.PostgreSQL/RetentionCleanupService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ async Task CleanupTable(string tableName, string dateColumn, DateTime cutoffDate
6363
// Delete in batches
6464
var sql = $@"
6565
DELETE FROM {tableName}
66-
WHERE {dateColumn} < @cutoff
67-
LIMIT 1000;";
66+
WHERE ctid IN (
67+
SELECT ctid FROM {tableName}
68+
WHERE {dateColumn} < @cutoff
69+
LIMIT 1000
70+
);";
6871

6972
await using var cmd = new NpgsqlCommand(sql, conn);
7073
cmd.Parameters.AddWithValue("cutoff", cutoffDate);

0 commit comments

Comments
 (0)