Skip to content

[344] Configure SQLite index structures for sqlite_vacuum_cleaner - #377

Merged
2 commits merged into
Goldii-locks:mainfrom
ToryMic:fix/344-configure-sqlite-index-structures-for-sqlite_vacuum_cleaner
Aug 30, 2026
Merged

[344] Configure SQLite index structures for sqlite_vacuum_cleaner#377
2 commits merged into
Goldii-locks:mainfrom
ToryMic:fix/344-configure-sqlite-index-structures-for-sqlite_vacuum_cleaner

Conversation

@ToryMic

@ToryMic ToryMic commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Optimizes the SQLite table index schemas accessed by sqlite_vacuum_cleaner to improve lookup speeds.

  • Adds migration 6 that creates the vacuum cleaner lookup indexes:
    idx_events_created_at, idx_events_ledger_sequence, and the composite
    idx_events_created_at_ledger / idx_events_ledger_created_at.
  • Exports VACUUM_CLEANER_INDEXES / getVacuumIndexNames() and adds
    ensureVacuumIndexes() so databases predating migration 6 can self-heal.
  • Adds vacuumExplainQueryPlan() / vacuumQueryPlanUsesIndex() helpers that
    mirror the existing ledger_range_tracker pattern.

Validation

  • Tests run EXPLAIN QUERY PLAN against the cleaner's retention-time and
    ledger-range lookups and assert the indexes are utilized
    (both the DELETE
    predicates used by the cleaner and the SELECT equivalents).
  • tsc --noEmit, npm test (957 tests), and npm run build all pass.

Also includes small repairs to pre-existing CI failures so this branch is green.

Closes 344
Closes #344

ToryMic added 2 commits August 28, 2026 20:39
- Import jest from @jest/globals in failover-recovery tests that used the
  global (ReferenceError: jest is not defined)
- Drop fake-timer usage that captured the mocked setTimeout and hung
- Type logger.warn/debug spy calls to satisfy strict tsc
- Export SCHEMA_MANAGER_INDEXES from db.ts and import it in the schema
  manager test (ReferenceError)
- Make the Goldii-locks#186 migration-count assertion robust to future migrations
- Accept opts argument in the indexer-runner-historical-sync getEvents mock
…i-locks#344)

Optimize the events table index schema used by sqlite_vacuum_cleaner so its
row lookups resolve through indexes instead of full scans:
- Add migration 6 creating the vacuum cleaner lookup indexes
  (idx_events_created_at, idx_events_ledger_sequence, and the composite
  idx_events_created_at_ledger / idx_events_ledger_created_at).
- Export VACUUM_CLEANER_INDEXES + getVacuumIndexNames() so tests and
  operators can reference the managed index names.
- Add ensureVacuumIndexes() for self-healing databases that predate
  migration 6.
- Add vacuumExplainQueryPlan() / vacuumQueryPlanUsesIndex() helpers mirroring
  ledger_range_tracker.

Tests run EXPLAIN QUERY PLAN against the cleaner's retention-time and
ledger-range predicates and assert the managed indexes are utilized for the
lookups. Also make the indexer migration-count assertion robust to future
migrations.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@ToryMic 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! 🚀

Learn more about application limits

@godamongstmen897 godamongstmen897 closed this pull request by merging all changes into Goldii-locks:main in 9e42e6f Aug 30, 2026
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.

Configure SQLite index structures for sqlite_vacuum_cleaner

2 participants