Skip to content

Commit 912afca

Browse files
committed
Speed up cleanup query a little bit
1 parent 4b12efb commit 912afca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Cavil/Model/Packages.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ sub obsolete_old_packages ($self, $days_to_keep_orphaned, $days_to_keep_orphaned
470470
SELECT id FROM (
471471
SELECT id, ROW_NUMBER() OVER (PARTITION BY name ORDER BY id DESC) row_no
472472
FROM bot_packages LEFT JOIN bot_package_products ON bot_package_products.package = bot_packages.id
473-
WHERE state != 'new' AND checksum IS NOT NULL
473+
WHERE state != 'new' AND checksum IS NOT NULL AND obsolete = false
474474
AND imported < NOW() - (INTERVAL '1 days' * ?)
475475
AND bot_package_products.product IS NULL
476476
) AS a
@@ -483,7 +483,7 @@ sub obsolete_old_packages ($self, $days_to_keep_orphaned, $days_to_keep_orphaned
483483
"UPDATE bot_packages SET obsolete = true WHERE id IN (
484484
SELECT id
485485
FROM bot_packages LEFT JOIN bot_package_products ON bot_package_products.package = bot_packages.id
486-
WHERE state != 'new' AND obsolete != true AND checksum IS NOT NULL
486+
WHERE state != 'new' AND obsolete != true AND checksum IS NOT NULL AND obsolete = false
487487
AND imported < NOW() - (INTERVAL '1 days' * ?)
488488
AND bot_package_products.product IS NULL
489489
)", $days_to_keep_orphaned

0 commit comments

Comments
 (0)