perf(db): drop redundant idx_edges_source / idx_edges_target#142
Merged
Conversation
Both narrow indexes are fully covered by the existing (source, kind) and (target, kind) composites via SQLite's left-prefix scan, so they're dead weight on every write. Empirical measurements (from the spike script in PR #122 on a 50K-node / 250K-edge synthetic DB): - DB size: 34.7 MB → 27.0 MB (-22.2%) - Bulk insert (250K edges): 590ms → 431ms (1.37× faster) - source/target lookup latency: no regression Adds migration v4 to drop both on existing databases; fresh-DB schema no longer creates them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
idx_edges_source,idx_edges_target) that are fully covered by the existing(source, kind)and(target, kind)composites via SQLite's left-prefix scan.CURRENT_SCHEMA_VERSION3 → 4) to drop them on existing databases; fresh-DB schema no longer creates them.Salvaged from #122, which bundled the same fix with the unmerged file-based migrations refactor. This is the standalone, inline-migration version.
Why it's safe
WHERE source = ?idx_edges_sourceidx_edges_source_kind(left-prefix, covering)WHERE target = ?idx_edges_targetidx_edges_target_kind(left-prefix, covering)WHERE source = ? AND kind = ?idx_edges_source_kindWHERE target = ? AND kind = ?idx_edges_target_kindEmpirical numbers (from #122's spike on 50K-node / 250K-edge DB)
Test plan
npx tsc --noEmitcleannpm test— 416/416 passfoundation.test.tsandpr19-improvements.test.ts🤖 Generated with Claude Code