Skip to content

Escrow.status has no explicit database index despite being filtered directly in hot query paths #97

Description

@chonilius

Escrow (src/common/entities/escrow.entity.ts) has no @Index on status, yet SponsorsService.budgetLocked (src/sponsors/sponsors.service.ts) runs WHERE escrow.sponsorId = :sponsorId AND escrow.status = :status on every sponsor dashboard load, and EscrowService's internal lookups filter by status implicitly via assertLocked after fetching by id. As the escrows table grows, budgetLocked's query — which has no sponsorId index either, compounding the problem — degrades from an index scan to a much more expensive plan.

This is a narrower, more specific gap than #13's general call for composite indexes on "webhook issue lookup, bounty status filtering, payment aggregation" — it names the exact table/columns and the exact two call sites (SponsorsService.budgetLocked's sponsorId+status filter, and any future status-scoped escrow listing) that #13 doesn't explicitly enumerate.

Fix: add a composite index on escrows(sponsorId, status) to directly serve budgetLocked's query pattern.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workinghelp wantedExtra attention is neededperformancePerformance/optimization issuevery hardVery difficult task, expert-level effort required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions