some backend queries fetch large result sets, join on unindexed JSON fields, or rely on sorting/indexes that do not exist in Supabase, causing slow snapshots and timeouts under load.
Affected areas: app/backend/src/ingestion/event.repository.ts, app/backend/src/transactions/transaction.repository.ts, app/backend/src/refunds/refund.repository.ts, app/backend/supabase/migrations/*, app/backend/src/common/pagination/*.
Implementation scope:
- Audit slow query plans and add appropriate Supabase indexes for common filters and orderings.
- Rewrite heavy joins into staged queries or materialized snapshots where needed.
- Add query timeout handling and degrade gracefully for dashboard endpoints.
- Add integration tests that assert query execution under realistic data volumes.
Acceptance criteria:
- Key backend queries use indexed filter/order columns and avoid full-table scans.
- Large pagination queries remain stable under synthetic load.
- Slow query regressions are caught by CI or test assertions.
some backend queries fetch large result sets, join on unindexed JSON fields, or rely on sorting/indexes that do not exist in Supabase, causing slow snapshots and timeouts under load.
Affected areas:
app/backend/src/ingestion/event.repository.ts,app/backend/src/transactions/transaction.repository.ts,app/backend/src/refunds/refund.repository.ts,app/backend/supabase/migrations/*,app/backend/src/common/pagination/*.Implementation scope:
Acceptance criteria: