hub: claim_request: drop the unused (status, lapses_at) index; index what the minute sweep reads
tsk-6yzyabwt7vb5 Proposed
Audit round 6 (tsk-hgnbapyw7hnh), read at 046a4d3b. Kind: debt (an unused index, a full scan on a timer).
What is wrong
ix_claim_request_status_lapses (status, lapses_at)(tables.py:2101, migration20261126090000_outside_claims.py:86) serves no query: the only filter onclaim_request.statusis indeclined_on(claim_requests.py:568), which is led by the member.claim_requests.sweepruns every minute withWHERE pending IS TRUE ORDER BY requested_at, id(claim_requests.py:1209-1211). The only index holdingpendingis the unique key on(task_id, pending), so the sweep scans the whole table, and settled rows are kept forever. The per-project reads (:151,:426,:1158) have the same shape.
Proposal
- One migration: drop
ix_claim_request_status_lapses, add an index the sweep and the per-project reads can use (e.g.(pending, requested_at)or(project_id, pending)), or move those reads tostatus = pendingwith an index led by status.
Effort / risk: S. Low; one migration, model and migration kept equal by test_schema.