aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-data-service/data-deletion.scm26
1 files changed, 18 insertions, 8 deletions
diff --git a/guix-data-service/data-deletion.scm b/guix-data-service/data-deletion.scm
index b48f78c..0dd4a78 100644
--- a/guix-data-service/data-deletion.scm
+++ b/guix-data-service/data-deletion.scm
@@ -425,15 +425,25 @@ WHERE build_server_id = $1
build-server-ids)))
(define (delete-unreferenced-derivations-source-files conn)
- (exec-query
- conn
- "
+ (define (delete-batch)
+ (exec-query
+ conn
+ "
DELETE FROM derivation_source_files
-WHERE NOT EXISTS (
- SELECT 1
- FROM derivation_sources
- WHERE derivation_source_file_id = derivation_source_files.id
-)"))
+WHERE id IN (
+ SELECT id
+ FROM derivation_source_files
+ WHERE NOT EXISTS (
+ SELECT 1
+ FROM derivation_sources
+ WHERE derivation_source_file_id = derivation_source_files.id
+ )
+ LIMIT 100
+)
+RETURNING id"))
+
+ (while (not (null? (delete-batch)))
+ #t))
(define (maybe-delete-derivation conn id)
(match (map