diff options
author | Denis Grebennicov <denis.grebennicov@mongodb.com> | 2022-06-27 11:00:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-27 12:17:31 +0000 |
commit | aef7e4b58194476c1fbd952d5181e995d70f4b7c (patch) | |
tree | 8b0750f4b5efaf1f71938114d54397f3602f08bb /src/mongo/db/query | |
parent | 61eadca1b33563d68be35b382fab678e82464873 (diff) | |
download | mongo-aef7e4b58194476c1fbd952d5181e995d70f4b7c.tar.gz |
SERVER-67098 Add a server parameter to disable plan caching
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r-- | src/mongo/db/query/canonical_query.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/query/classic_plan_cache.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/query/query_knobs.idl | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp index 6449c5241fc..f340b4811d7 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -199,7 +199,10 @@ Status CanonicalQuery::init(OperationContext* opCtx, } auto unavailableMetadata = validStatus.getValue(); _root = MatchExpression::normalize(std::move(root)); - if (feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV()) { + + // If caching is disabled, do not perform any autoparameterization. + if (!internalQueryDisablePlanCache.load() && + feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV()) { const bool hasNoTextNodes = !QueryPlannerCommon::hasNode(_root.get(), MatchExpression::TEXT); if (hasNoTextNodes) { diff --git a/src/mongo/db/query/classic_plan_cache.cpp b/src/mongo/db/query/classic_plan_cache.cpp index 5f33481fef6..683b4b3660a 100644 --- a/src/mongo/db/query/classic_plan_cache.cpp +++ b/src/mongo/db/query/classic_plan_cache.cpp @@ -126,6 +126,10 @@ std::string SolutionCacheData::toString() const { } bool shouldCacheQuery(const CanonicalQuery& query) { + if (internalQueryDisablePlanCache.load()) { + return false; + } + const FindCommandRequest& findCommand = query.getFindCommandRequest(); const MatchExpression* expr = query.root(); diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl index 53c1e5e7617..9fa82639f51 100644 --- a/src/mongo/db/query/query_knobs.idl +++ b/src/mongo/db/query/query_knobs.idl @@ -129,6 +129,13 @@ server_parameters: # Plan cache # + internalQueryDisablePlanCache: + description: "Disables caching of query plans for both classic and SBE engines." + set_at: [ startup ] + cpp_varname: "internalQueryDisablePlanCache" + cpp_vartype: AtomicWord<bool> + default: false + internalQueryCacheMaxEntriesPerCollection: description: "The maximum number of entries allowed in a given collection's plan cache. Applies only to the classic plan cache, not to the SBE plan cache." |