Repository navigation
perf(consolidation): check for pending work without counting the bank - #6403
Merged
Merged
Conversation
- read idx_memory_units_unconsolidated newest first: consolidation works oldest first, so failed facts pile up at the old end (same reasoning as b2429c65cc20); measured ~25 ms -> ~12 ms with 100k failed facts - drop the Postgres-only gate: the LIMIT 1 shape rewrites cleanly on Oracle (see pg/reads.py), so Oracle no longer falls back to the full count - say in the test why it uses direct SQL
This was referenced Nov 6, 2026
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.
Closes #6326. Contributor patch by @harshitgupta31415 (commit kept with their authorship), plus two follow-ups.
After a memory or document is deleted, the refresh scheduler only needs to know whether any fact is still waiting for consolidation. It used to count the whole bank to find out. It now stops at the first such fact, using
idx_memory_units_unconsolidated. The filter is the same one thependingcount uses, so the answer is identical.Follow-ups on top of the original patch:
b2429c65cc20). Reading oldest first would step over every one of them.LIMIT 1shape rewrites cleanly on Oracle (seepg/reads.py), so Oracle no longer falls back to the full count.Measured on 1M rows in one bank (PG16, warm cache):
Tests:
test_pending_consolidation_probe.py(new),test_memories_extension.py,test_mental_model_retractions.py,test_delete_document_concurrency.py.