From 7c59f2b66284b5b561c5368a0c834640ae0e611e Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan.goodliffe@octal.co.uk>
Date: Thu, 23 Apr 2026 10:11:13 +0100
Subject: Add BRIN index to access_log.request_time and improve purge

Purge is now fully request_time based and not hacked around id ranges.
---
 src/schema.sql | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'src/schema.sql')

diff --git a/src/schema.sql b/src/schema.sql
index b211505..9d39bcd 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -107,6 +107,8 @@ CREATE TABLE access_log(
 	CONSTRAINT fk_access_log_content_type FOREIGN KEY (content_type) REFERENCES entities(id) ON UPDATE CASCADE
 );
 
+CREATE INDEX idx_access_log_request_time ON access_log USING BRIN(request_time) WITH (autosummarize = TRUE);
+
 CREATE OR REPLACE VIEW access_log_view AS
 SELECT
 	l.id,
-- 
cgit v1.3

