Reduce webhook delivery cleanup impact (#2550)

* Add index on webhook_deliveries.created_at

The stale scope (WHERE created_at < ?) and ordered scope
(ORDER BY created_at DESC) both benefit from this index.
Without it, Webhook::Delivery.cleanup does a full table scan.

* Run webhook delivery cleanup every 15 minutes

Each run now deletes ~15 minutes of newly-stale records instead
of ~4 hours worth, a 16x reduction in per-run write volume.
This commit is contained in:
Jeremy Daer
2026-02-16 14:28:05 -08:00
committed by GitHub
parent a1e96670ce
commit bc76633f77
4 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ production: &production
schedule: every hour at minute 12
cleanup_webhook_deliveries:
command: "Webhook::Delivery.cleanup"
schedule: every 4 hours at minute 51
schedule: every 15 minutes
cleanup_magic_links:
command: "MagicLink.cleanup"
schedule: every 4 hours