Skip to content

fix(prune): batch DELETE IN to stay under SQLite var limit (#43)#45

Merged
scbrown merged 1 commit into
mainfrom
fix/bo-43-batch-prune-delete
Jul 14, 2026
Merged

fix(prune): batch DELETE IN to stay under SQLite var limit (#43)#45
scbrown merged 1 commit into
mainfrom
fix/bo-43-batch-prune-delete

Conversation

@scbrown

@scbrown scbrown commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #43. delete_file_hashes built a single DELETE FROM file_hashes WHERE file_path IN (?1..?N) binding one variable per file. When a source with more than SQLITE_MAX_VARIABLE_NUMBER (32766) files was pruned in one pass (source removed, repointed, or full reindex), the statement exceeded the limit and aborted, leaving the index inconsistent until a --force reindex — silently degrading search coverage.

Fix

  • Chunk the delete into batches of SQLITE_MAX_BIND_VARS (30k) ids.
  • Run all chunks inside one transaction so the prune remains atomic.

Test

  • New regression test_delete_file_hashes_exceeds_bind_var_limit inserts 40k rows and deletes them all; the old unbatched path fails this.
  • Existing test_delete_file_hashes still passes.

🤖 Generated with Claude Code

An unbatched `DELETE FROM file_hashes WHERE file_path IN (?1..?N)` binds one
variable per file. When a source with more than SQLITE_MAX_VARIABLE_NUMBER
(32766) files is pruned in one pass, the statement exceeds the limit and
aborts, leaving the index inconsistent until a --force reindex.

Chunk the delete into batches of 30k ids, all within a single transaction so
the prune stays atomic. Add a regression test that deletes 40k rows.

Fixes #43

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VsuPDxSUjMYqHvQyPvSAPW
@scbrown
scbrown merged commit c63cf84 into main Jul 14, 2026
1 check passed
@scbrown
scbrown deleted the fix/bo-43-batch-prune-delete branch July 14, 2026 02:23
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.

Unbatched DELETE ... IN (?) exceeds SQLite variable limit (32766) when pruning a large source

1 participant