Skip to content

Fix/stream event composite index - #1315

Open
Seunfunmi-319509 wants to merge 4 commits into
LabsCrypt:mainfrom
Seunfunmi-319509:fix/stream-event-composite-index
Open

Fix/stream event composite index#1315
Seunfunmi-319509 wants to merge 4 commits into
LabsCrypt:mainfrom
Seunfunmi-319509:fix/stream-event-composite-index

Conversation

@Seunfunmi-319509

Copy link
Copy Markdown

PR Summary

Added a composite database index to optimize cancelled and completed stream status-filter queries.

What was done
Added a composite (streamId, eventType) index to the StreamEvent model.
Added the corresponding Prisma migration.
Optimized the EXISTS-style event filtering used by stream listing and repository queries.
Verified the query execution plan with EXPLAIN ANALYZE to confirm the composite index is utilized.
Acceptance Criteria

Composite (streamId, eventType) index added.

Database migration included.

Cancelled/completed status-filtered queries use the new index.

Query performance is improved for growing event volumes.

closes #1248

Seunfunmi-319509 and others added 4 commits August 29, 2026 22:02
…and keeper-key model

Both indexerService.ts and soroban-indexer.service.ts reference
"docs/ARCHITECTURE.md for the full indexer ownership model" but no
such file existed in backend/docs/. This created a broken cross-
reference for contributors investigating the dual-indexer race (LabsCrypt#801)
and the keeper-key authorization model.

This adds backend/docs/ARCHITECTURE.md documenting:
- Indexer ownership: which of the three similarly-named files is
  authoritative, the dual-indexer race, and the phase-out plan
- SSE broadcast flow: end-to-end path from Soroban RPC through the
  worker, DB, SSE service, Redis fanout, to the frontend
- Keeper-key authorization: the custodial vs non-custodial signing
  model, the KEEPER_SECRET_KEY role, and the security boundary

Closes LabsCrypt#1299

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Adds tests for the three untested error branches in connectFreighter():
1. FreighterNotInstalledError when isConnected returns false
2. getAddress failure with no address or explicit error
3. getNetworkDetails catch fallback

Closes LabsCrypt#1287

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
listStreams and findStreams in stream.repository.ts filter by
events: { some: { eventType: X } } for cancelled/completed status,
which is an EXISTS-style subquery on StreamEvent. The existing
single-column indexes on streamId and eventType cannot efficiently
serve this pattern.

Adds @@index([streamId, eventType]) to the StreamEvent model and a
corresponding migration. This allows Postgres to use an index-only
scan for the status-filtered listing queries without scanning all
events per stream.

Closes LabsCrypt#1248

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Audit] Missing composite index for the "cancelled/completed" status-filter query pattern

1 participant