Fix/stream event composite index - #1315
Open
Seunfunmi-319509 wants to merge 4 commits into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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