feat(indexer): configure SQLite index structures for indexer_runner - #359
Merged
3 commits merged intoAug 30, 2026
Merged
Conversation
…-locks#250) Optimize lookup indexes for the tables the indexer_runner execution loop accesses and verify index utilization with EXPLAIN QUERY PLAN. - db.ts: add migration v5 with idx_monitored_contracts_active (backing getActiveContractIds WHERE active = 1, the per-cycle poll lookup) and idx_events_created_at (backing MAX(created_at) status aggregation). Export INDEXER_RUNNER_INDEXES for the EXPLAIN tests. - duplicate-prevention.ts: create idx_sync_ranges_ledgers on (start_ledger, end_ledger) at table creation, backing isLedgerSynced range lookups. Export SYNC_RANGES_INDEXES. - indexer-indexes.test.ts: new suite asserting each plan references the expected index via EXPLAIN QUERY PLAN, plus functional checks. - indexer.test.ts: update expected migration count 4 -> 5.
|
@hauwauyahass-byte Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Author
|
@Goldii-locks @hauwauyahass-byte Status update for #250: build fails in TypeScript tests: indexer event mock signature and SQLite schema-manager test/API mismatches remain; no code change pushed. Please review the linked CI result and rerun checks where applicable. |
Author
|
@Goldii-locks @hauwauyahass-byte PR #359 references Fixes #250. Please review/rerun CI. |
9e42e6f
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.
Closes #250
Summary
Configures SQLite index structures for the
indexer_runnerexecution loop and verifies index utilization withEXPLAIN QUERY PLAN.The poller (
src/indexer/poller.ts) hits a handful of lookup queries every cycle. These were either full table scans (no covering index) or relying on incidental ones. This PR adds deliberate indexes for the hot paths:monitored_contracts (active)—idx_monitored_contracts_activebacksgetActiveContractIds()(WHERE active = 1), the lookup the runner performs on every poll cycle. Added via migration v5.events (created_at)—idx_events_created_atbacks theMAX(created_at)status aggregation ingetIndexerStatusData().sync_ranges (start_ledger, end_ledger)—idx_sync_ranges_ledgersbacks the range lookup inisLedgerSynced()during historical backfill (created alongside the table, sincesync_rangesis defined outside the migration array).Verification
__tests__/indexer-indexes.test.tswhich seeds representative rows and runsEXPLAIN QUERY PLANagainst each runner query, asserting the expected index is referenced, plus functional checks (getActiveContractIds,getIndexerStatusData,isLedgerSynced).indexer.test.tsmigration-count assertion updated 4 -> 5 for the new migration.Local test results
jest(new indexer-indexes suite): 4 passed, 0 failedjestfull suite: my suites green; the only failing suites are pre-existing upstream failures unrelated to this change (ledger-range-tracker-improvements.test.tsfails to load — imports non-existentDEFAULT_LEDGER_RANGE_FAILURE_THRESHOLD;poller-alerting-diagnostics.test.tspre-existing) that also fail on the base branch.tsc -p tsconfig.build.json: my changed files type-check; remaining errors are pre-existing inpoller.ts(unrelated).Fixes #250