Skip to content

fix(sqlite): WAL checkpoint + add view_index for mmap loading#11

Merged
anoop-narang merged 3 commits intomainfrom
fix/view-index-and-wal-checkpoint
Mar 23, 2026
Merged

fix(sqlite): WAL checkpoint + add view_index for mmap loading#11
anoop-narang merged 3 commits intomainfrom
fix/view-index-and-wal-checkpoint

Conversation

@anoop-narang
Copy link
Copy Markdown
Collaborator

Summary

  • WAL checkpoint after open_or_build — data written during build was only in the WAL file and could be lost on process restart, causing empty SQLite query results when reloading the .db
  • view_index on USearchIndexConfig — memory-maps the index file instead of loading into RAM, keeping resident memory proportional to working set rather than full index size
  • New optimizer rule tests — covers the SELECT-only-distance pattern (no base columns projected)

Test plan

  • All 23 optimizer rule tests pass (including 3 new)
  • All 13 execution tests pass
  • cargo clippy -- -D warnings clean
  • Verified WAL checkpoint fix with runtimedb engine restart integration test

Data written during build may only exist in the WAL file. Without an
explicit checkpoint, the data can be lost if the process exits before
SQLite performs a passive checkpoint. This caused empty query results
when reloading the .db file after an engine restart.
view_index uses mmap instead of loading the full index into RAM,
keeping resident memory proportional to the working set. Prefer this
for the reload-from-disk path where the index file is already local.
Covers the case where the SELECT list contains only the distance UDF
and no base table columns, with bare and qualified table references.
@anoop-narang anoop-narang merged commit f16ec0c into main Mar 23, 2026
5 checks passed
@anoop-narang anoop-narang deleted the fix/view-index-and-wal-checkpoint branch March 23, 2026 11:50
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.

1 participant