-- Index the retention reaper's scan. reap_terminal deletes -- WHERE state IN ('done','dead') AND updated_at < now() - interval -- which had no supporting index, so each daily sweep sequential-scanned the whole -- crawler_jobs table to find expired terminal rows (audit M5). A partial index on -- updated_at over just the terminal states makes the batched reaper's per-batch -- SELECT index-backed. CREATE INDEX crawler_jobs_terminal_reap_idx ON crawler_jobs (updated_at) WHERE state IN ('done', 'dead');