Repository navigation
Look up fact successors within their knowledge base - #1512
Merged
WaylandYang merged 1 commit intoNov 18, 2026
Merged
Conversation
Signed-off-by: Maya Kid <BinjunYann@gmail.com>
WaylandYang
approved these changes
Nov 18, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thanks — this closes the follow-up from #1501, and the same-base foreign key from 0070 guarantees the added kb_id scope never drops a successor. The measurements are appreciated. Merging.
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.
Why
The successor lookups in evidence attachment and merge rollback only supplied
supersedes. The existingfacts_kb_supersedes_fk_idxstarts withkb_id, so these queries scanned a broad slice of the index or hashed successors from every knowledge base.This follows up on the review of #1501.
What changes
FOR SHAREquery, then use it to look up the next revision.How it was checked
Compared the complete prepared SQL on Linux PostgreSQL 16.15 with 500,012 facts across 100 knowledge bases, using all migrations from
4ed8a59f. Medians use five paired runs after warmup and measure statement execution.kb_idEXPLAIN (ANALYZE, BUFFERS)shows equality on both index keys for selective lookups and a knowledge-base-scoped bitmap scan for the bulk cases. The test also measured generic prepared plans and the existing row lock query.The next revision matched across live and invalidated siblings, tied ranking keys, and no-successor cases. Recursive ID sets matched for branches, cycles, duplicate and missing roots, and the 1,000-root batch. The unordered bulk CTE emitted those IDs in a different physical order, and its callers use them for membership and explicitly sort timeline lock keys. Both DELETE variants removed the exact same fact/chunk pairs under rollback.
The full
utopia-storesuite passed on Linux with PostgreSQL required, including concurrent evidence attachment during a rewrite and the two merge rollback regressions. Formatting andutopia-storeClippy also passed.Before review