From aa8f64a3e140e74a1f8d0074b606dd1f8560ad0a Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan.goodliffe@octal.co.uk>
Date: Mon, 8 Jun 2026 11:27:49 +0100
Subject: Don't order rows when purging

The need to purge rows in request_time order is not necessary (all rows
will be deleted at some point in the process anyway) and is otherwise
extremely expensive. Removing the order by clause is a roughly 300x
speed up.
---
 src/sql/accessLogPurgeOld.sql | 2 --
 1 file changed, 2 deletions(-)

(limited to 'src/sql/accessLogPurgeOld.sql')

diff --git a/src/sql/accessLogPurgeOld.sql b/src/sql/accessLogPurgeOld.sql
index 00e55b5..616b3a6 100644
--- a/src/sql/accessLogPurgeOld.sql
+++ b/src/sql/accessLogPurgeOld.sql
@@ -5,8 +5,6 @@ WITH delete_batch AS (
 		access_log
 	WHERE
 		request_time < CURRENT_DATE - ?::interval
-	ORDER BY
-		request_time
 	FOR UPDATE
 LIMIT ?)
 DELETE FROM access_log AS al USING delete_batch AS del
-- 
cgit v1.3

