Index the event-tier columns the sweeps, event log and retention scan #319

Merged
clawbot merged 3 commits from issue-314-event-tier-indexes into next 2026-09-28 14:13:23 +02:00
3 Commits
Author SHA1 Message Date
sneak 49def467b1 Put deleted_at in the event-tier indexes so SQLite uses them
check / check (push) Successful in 3m16s
GORM adds deleted_at IS NULL to these queries, and SQLite, which has no
table statistics here, preferred the deleted_at index to the new
single-column ones wherever a column is matched against several values
or compared with <. The event log's attempt load, retention's lookups
of expired events and their deliveries, and the queue-depth sampler
still read every live row. Each index now also covers deleted_at,
first in the events index because created_at is compared with <;
events keeps its created_at index for retention's final delete. A test
checks SQLite's plan for each statement as GORM builds it.

Model: opus-5-5
2026-09-28 11:30:32 +00:00
sneak 12e6c3bf3e Align DeliveryResult tags and make the index table test-local
Re-align the json tag column in DeliveryResult after the wider
DeliveryID gorm tag, and move the test's index table out of package
scope into the test function.

Model: opus-5-5
2026-09-28 11:02:08 +00:00
sneak 2dc6f1f077 Index the event-tier columns the sweeps, event log and retention scan (closes #314)
The per-webhook tables declared no secondary indexes, so the recovery
and sweep queries (by delivery status, every minute), the event log
(deliveries by event, results by delivery) and retention (events by
age) each scanned a whole table. Add indexes through GORM model tags so
AutoMigrate creates them on a fresh and on an existing per-webhook
database. events.created_at is indexed by overriding the embedded
BaseModel field on Event alone, leaving the other tables' created_at
unindexed. A test drops the indexes from an opened database, reopens it,
and asserts the open recreated them. The README Data Model section lists
the indexes.

Model: opus-4-8
2026-09-28 11:02:08 +00:00