Description
Add and validate Prisma indexes that support the high-frequency settlement and SEP-24 worker queries. This keeps status polling and background processing responsive as the number of groups, expenses, and transactions grows.
Context & Requirements
The API uses Prisma and a dedicated worker at src/worker/index.ts. Worker queries commonly need to find records by processing status, retry eligibility, update time, or group ownership. Without suitable composite indexes, those queries can scan large tables and delay all jobs. Indexes must reflect the actual filters and ordering in the code, not be added generically.
Avoid changing application semantics or removing existing indexes. Consider write overhead and index selectivity, and use a migration that can be deployed safely with the repository's Prisma workflow. The change should also identify queries that need a bounded limit so an index does not mask unbounded work.
Acceptance Criteria
Implementation Guidance
Inspect the Prisma schema, migrations, and all settlement or SEP-24 queries under src. Trace the worker selection logic from src/worker/index.ts to the relevant service methods before selecting indexes. Prefer the smallest set of composite indexes that covers real filters and sort order. If the database provider has limitations on online index creation, document the deployment consideration rather than hiding it in application code.
Testing & Validation
Add or update repository tests to confirm worker selection and pagination behavior remain correct. Seed representative records using the existing prisma/seed.ts pattern or a test fixture, then capture query plans or timing before and after the migration. Run npm run prisma:generate, npm run build, npm test, and npm run lint.
Submission Guidelines
Assignment is required before starting. Open one PR that includes Closes #<issue-number>, includes the Prisma migration, and explains the workload and query evidence behind each index.
Wave complexity: Medium
Description
Add and validate Prisma indexes that support the high-frequency settlement and SEP-24 worker queries. This keeps status polling and background processing responsive as the number of groups, expenses, and transactions grows.
Context & Requirements
The API uses Prisma and a dedicated worker at
src/worker/index.ts. Worker queries commonly need to find records by processing status, retry eligibility, update time, or group ownership. Without suitable composite indexes, those queries can scan large tables and delay all jobs. Indexes must reflect the actual filters and ordering in the code, not be added generically.Avoid changing application semantics or removing existing indexes. Consider write overhead and index selectivity, and use a migration that can be deployed safely with the repository's Prisma workflow. The change should also identify queries that need a bounded limit so an index does not mask unbounded work.
Acceptance Criteria
src/worker/index.ts.Implementation Guidance
Inspect the Prisma schema, migrations, and all settlement or SEP-24 queries under
src. Trace the worker selection logic fromsrc/worker/index.tsto the relevant service methods before selecting indexes. Prefer the smallest set of composite indexes that covers real filters and sort order. If the database provider has limitations on online index creation, document the deployment consideration rather than hiding it in application code.Testing & Validation
Add or update repository tests to confirm worker selection and pagination behavior remain correct. Seed representative records using the existing
prisma/seed.tspattern or a test fixture, then capture query plans or timing before and after the migration. Runnpm run prisma:generate,npm run build,npm test, andnpm run lint.Submission Guidelines
Assignment is required before starting. Open one PR that includes
Closes #<issue-number>, includes the Prisma migration, and explains the workload and query evidence behind each index.Wave complexity: Medium