Repository navigation
perf(retain): read existing documents' tags in one go for a scoped retain - #6402
Merged
Merged
Conversation
…tain (#6327) A tag-scoped retain checked each existing document with its own query. Read them together (groups of 1,000, the Oracle IN-list cap) and check in the same order. A store record without tags still counts as an existing document, so the allow/deny answer is unchanged. Thanks @harshitgupta31415 for the report and benchmark.
… neutral test comment
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.
Fixes #6327 (thanks @harshitgupta31415 for the report, numbers and patch).
What changes
A caller with a tag scope who retains a batch into existing documents had each document checked with its own query (3,500 docs ≈ 3 s). Now the tags are read together, in groups of 1,000, and checked in the same order.
Same answers as before
existing_documents_tags: Postgres reads all rows at once; other stores keep the per-document read.documents_tagsfor other stores: that one drops a record with no tags field, which would make an existing document look new and let a restricted writer through. A test covers this.pg/documents.documents_tagsnow reads in groups of 1,000, since Oracle expands= ANYinto an IN list capped at 1,000 (also fixes the source-text visibility read past 1,000 docs on Oracle).Tests
test_tag_scope: a batch mixing a new doc, an allowed doc and a forbidden doc is refused with 403 naming the forbidden one.