Drop redundant idx_jobs_pending_by_source index

has_pending() already uses the leading column of uq_jobs_live
(source_id) with the same WHERE clause. The extra index just adds
write amplification on every insert/claim/complete without improving
reads.
This commit is contained in:
Chris McDonough 2026-06-01 09:24:11 -04:00
parent 48826031ac
commit 5010069474

View file

@ -40,12 +40,6 @@ ON jobs(scheduled_at)
WHERE status = 'queued'
"""
JOBS_PENDING_BY_SOURCE_INDEX = """
CREATE INDEX IF NOT EXISTS idx_jobs_pending_by_source
ON jobs(source_id)
WHERE status IN ('queued', 'claimed')
"""
JOBS_SUCCEEDED_COMPLETED_INDEX = """
CREATE INDEX IF NOT EXISTS idx_jobs_succeeded_completed
ON jobs(completed_at)
@ -79,7 +73,6 @@ ALL_DDL: tuple[str, ...] = (
JOBS_DDL,
JOBS_LIVE_INDEX,
JOBS_CLAIMABLE_INDEX,
JOBS_PENDING_BY_SOURCE_INDEX,
JOBS_SUCCEEDED_COMPLETED_INDEX,
SYNC_STATE_DDL,
SCHEMA_VERSION_DDL,