perf(filtering): split METADATA into thin + fat tables (v2 schema)#144
Open
vlasky wants to merge 1 commit into
Open
perf(filtering): split METADATA into thin + fat tables (v2 schema)#144vlasky wants to merge 1 commit into
vlasky wants to merge 1 commit into
Conversation
Re-sequencing after deletes now touches only a ~50 byte/row thin table instead of rewriting full ~27KB rows. Benchmarked at 8ms for 20K rows vs 210ms (v1) / 940ms (v0). - METADATA retains small filterable columns (_subset_, file, name, etc.) - METADATA_CONTENT holds large TEXT columns (code, signature, imports) - Linked by stable monotonic _content_id_ (never re-sequenced) - v0/v1 code paths preserved for backward compat reads - FTS rebuild/update_rows adapted to JOIN for v2 layout - INDEX_FORMAT_VERSION bumped to 2 (triggers full rebuild on upgrade) - Removed v0->v1 in-place migration; format mismatches now full-rebuild
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
Splits the single METADATA table into a thin table (~50 bytes/row) and a fat METADATA_CONTENT table (large TEXT columns), linked by a stable monotonic
_content_id_. Re-sequencing after deletes now touches only the thin table, making performance position-independent.Benchmarks (20K rows, 27KB each, delete near position 0):
Design
METADATAretains_subset_,_content_id_FK, and small filterable columns (file, name, line, unit_type, language, complexity, booleans)METADATA_CONTENTholds large TEXT columns (code, signature, docstring, parameters, calls, etc.) keyed by_content_id_INTEGER PRIMARY KEY_content_id_is stable and monotonic - never re-sequenced on deletePRAGMA user_version = 2marks the new layoutBackward compatibility
INDEX_FORMAT_VERSIONbumped to 2 in colgrep, triggering a full rebuild on upgrade (no in-place migration needed)Changes
next-plaid/src/filtering.rs: v2create,update_v2,delete_v2,get_v2,update_where_v2, JOIN-basedwhere_condition/where_condition_regexpfor fat column queriesnext-plaid/src/text_search.rs: FTSrebuild()/update_rows()adapted to JOIN for v2colgrep/src/index/state.rs:INDEX_FORMAT_VERSION: 1 -> 2colgrep/src/index/mod.rs: simplified format mismatch handling to full rebuildRelated
Test plan