From 1a02ebe862148fcac8806700cbec68a4aff93934 Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Thu, 22 Aug 2024 15:29:13 -0600 Subject: [PATCH] rsc: Optimize blob eviction query (#1635) --- rust/rsc/src/database.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/rsc/src/database.rs b/rust/rsc/src/database.rs index 7987dc52f..32db02268 100644 --- a/rust/rsc/src/database.rs +++ b/rust/rsc/src/database.rs @@ -685,12 +685,12 @@ pub async fn delete_unreferenced_blobs( r#" WITH eligible_blob_ids as ( - SELECT id FROM blob + SELECT DISTINCT id FROM blob WHERE updated_at <= $1 EXCEPT ( SELECT blob_id FROM output_file - UNION SELECT stdout_blob_id FROM job - UNION SELECT stderr_blob_id FROM job + UNION ALL SELECT stdout_blob_id FROM job + UNION ALL SELECT stderr_blob_id FROM job ) LIMIT $2 )