Docs/transaction query performance - #139
Merged
ndii-dev merged 2 commits intoJul 22, 2026
Merged
Conversation
added 2 commits
July 22, 2026 13:43
Root cause / design-decision rationale: The current implementation of filterAndSortTransactions in transaction-utils.ts uses in-memory filtering and sorting with no index support, which won't scale once mock-db.ts is replaced with a real database. This change documents the current complexity analysis and provides a detailed database migration and indexing spec to guide future work. - Complexity characterized (Big-O) and documented: Documented that filterAndSortTransactions is O(n log n) time and O(n) space, with sorting as the dominating factor. - DB translation spec produced: Created docs/transaction-query-performance.md with recommended table structure, indexes, and filter-to-SQL translations for future database migration. - Evidence the code actually runs: npm run test:unit completed successfully (build was blocked by missing environment variables, unrelated to our changes). - No regressions in adjacent behavior: Existing transaction filtering/sorting code remains unchanged, unit tests pass.
Root cause / design-decision rationale: The current implementation of filterAndSortTransactions in transaction-utils.ts uses in-memory filtering and sorting with no index support, which won't scale once mock-db.ts is replaced with a real database. This change documents the current complexity analysis and provides a detailed database migration and indexing spec to guide future work. - Complexity characterized (Big-O) and documented: Documented that filterAndSortTransactions is O(n log n) time and O(n) space, with sorting as the dominating factor. - DB translation spec produced: Created docs/transaction-query-performance.md with recommended table structure, indexes, and filter-to-SQL translations for future database migration. - Evidence the code actually runs: npm run test:unit completed successfully (build was blocked by missing environment variables, unrelated to our changes). - No regressions in adjacent behavior: Existing transaction filtering/sorting code remains unchanged, unit tests pass.
5 tasks
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.
Issue
Closes #77
Root cause
The
filterAndSortTransactionsfunction (used by bothmock-db.ts.queryTransactionsand directly by hooks) filters and sorts a full in-memory transaction array on every call without any indexing. While this works for the current mock-db fixture scale, it will be a performance bottleneck when replacingmock-db.tswith a real database, as real databases require explicit index definitions for efficient querying. We need to characterize the current complexity and specify how filter fields translate to indexedWHEREclauses to guide that future DB migration.What changed and why
We added
docs/transaction-query-performance.md, which contains:filterAndSortTransactionsimplementation as O(n log n) time (sorting dominates) and O(n) spacemock-db.tsis replaced by a real datastore, the team knows exactly what indexes to build and how to map existing filter parameters to efficient indexed queries. We did not modify the actual implementation because the issue explicitly states the DB migration itself is tracked separately, and this issue's deliverable is only the translation spec.Definition of done — addressed item by item
docs/transaction-query-performance.md(O(n log n) time, O(n) space with breakdown)docs/transaction-query-performance.mdEvidence this actually runs
Unit test run (truncated for brevity):
(All unit tests pass; final exit code 0. Build is blocked by missing environment variables unrelated to our changes:
NEXT_PUBLIC_STELLAR_NETWORKandSTELLAR_HORIZON_URL)Tests
No tests added or changed, as this issue is only about documenting complexity and producing a translation spec (not modifying code). Existing unit tests for
filterAndSortTransactionsandmock-dbremain unchanged and passing.Regression check
The only change is a new documentation file; no existing code was modified, so all adjacent behavior remains unaffected. Existing unit tests pass as before.
Checklist
console.log/TODO/debug code (only added a clean markdown file)