Repository navigation
perf(mongodb): classify metadata-backed :missing parameters once per query - #2211
Open
mauripunzueta wants to merge 1 commit into
Open
mauripunzueta wants to merge 1 commit into
mauripunzueta wants to merge 1 commit into
Conversation
…rs once per query Whether a :missing parameter is answered from missing_params was recomputed at every planning and execution stage, each time taking the tenant registry read lock and building an extractor. A registry reload mid-query could also make the planner and executor disagree. Classify once into MissingSupport (keyed by name and type, which is all the check depended on) and pass it, with the database handle, through planning and execution. retain_matching_candidates no longer calls get_database() per metadata-backed missing parameter, and the search total reuses the page's handle and classification. Closes #2007
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mauripunzueta
marked this pull request as ready for review
October 21, 2026 20:38
This branch has not been deployed
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 #2007.
What
On MongoDB, the check for whether a
:missingparameter is answered frommissing_paramsran again at every stage of a search. Each run took the tenant registry read lock and built a newSearchParameterExtractor. This PR classifies the parameters once per query and passes the result through planning and execution.MissingSupport(insearch_impl.rs), built byMongoBackend::classify_missing(tenant, resource_type, query). It takes one registry read lock and builds one extractor per query. It stores the(name, param_type)pairs thatmissing_paramsanswers. The old check depended only on those two fields (plus the index-ready flag), so the stored set gives the same answers it did.supports_indexed_missingandis_missing_resource_parameterare gone. Their callers useMissingSupport::supportsandMissingSupport::is_resource_parameterinstead.resource_filter_plan,plan_or_matching_ids,matching_resource_ids(and its seeded, complement-only and candidate-retention helpers),build_resource_filter,resource_order_page,sparse_page_id_set,search_param_sorted/resource_level_idsandcount_standard_with_facts.search_innercomputes it once. Its total count reuses that value and the same database handle, where it used to callget_database()again.retain_matching_candidatesnow receives the caller'sdband no longer callsself.get_database()for each metadata-backed missing parameter._contained=bothtop-level filter is classified against the contained type, which is the type it already used.storage.rsconditional-match callers only pass_id/_lastUpdatedparameters, so they useMissingSupport::none(). Behaviour there is unchanged.Acceptance criteria
get_database()inside per-parameter loopsTesting
Locally, against a single-node MongoDB 8.0.13 replica set, with
HFS_TEST_REQUIRE_MONGODB=1so that no Mongo-backed test could skip:cargo test -p helios-persistence --features mongodb --lib backends::mongodb→ 486 passed, 0 failed. This includes the planner'sexecution_testsandresource_page_tests.cargo test -p helios-persistence --features mongodb --test mongodb_tests→ 506 passed, 0 failed, 2 ignored (the#[ignore]d benchmarks).cargo clippy -p helios-persistence --features mongodb --tests: no new warnings. The only warnings in the files touched are existingcollapsible_iflints from the newer local toolchain, none of them on lines this PR changes.No new test is added. The change is a refactor that should not change behaviour, and the existing missing-index tests cover each branch that now reads
MissingSupport.