summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/query/get_executor.cpp30
-rw-r--r--src/mongo/db/query/sbe_cached_solution_planner.cpp2
2 files changed, 23 insertions, 9 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 0c12807f3e2..c0dde1cca1d 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -714,14 +714,10 @@ protected:
return std::make_unique<ResultType>();
}
- void initializePlannerParamsIfNeeded() {
- if (_plannerParamsInitialized) {
- return;
- }
- fillOutPlannerParams(_opCtx, getMainCollection(), _cq, &_plannerParams);
-
- _plannerParamsInitialized = true;
- }
+ /**
+ * Fills out planner parameters if not already filled.
+ */
+ virtual void initializePlannerParamsIfNeeded() = 0;
/**
* Constructs a PlanStage tree from the given query 'solution'.
@@ -787,6 +783,15 @@ public:
}
protected:
+ void initializePlannerParamsIfNeeded() final {
+ if (_plannerParamsInitialized) {
+ return;
+ }
+ fillOutPlannerParams(_opCtx, _collection, _cq, &_plannerParams);
+
+ _plannerParamsInitialized = true;
+ }
+
std::unique_ptr<PlanStage> buildExecutableTree(const QuerySolution& solution) const final {
return stage_builder::buildClassicExecutableTree(_opCtx, _collection, *_cq, solution, _ws);
}
@@ -988,6 +993,15 @@ public:
}
protected:
+ void initializePlannerParamsIfNeeded() final {
+ if (_plannerParamsInitialized) {
+ return;
+ }
+ fillOutPlannerParams(_opCtx, _collections, _cq, &_plannerParams);
+
+ _plannerParamsInitialized = true;
+ }
+
std::unique_ptr<SlotBasedPrepareExecutionResult> buildIdHackPlan() {
// Auto-parameterization currently only works for collection scan plans, but idhack plans
// use the _id index. Therefore, we inhibit idhack when auto-parametrization is enabled.
diff --git a/src/mongo/db/query/sbe_cached_solution_planner.cpp b/src/mongo/db/query/sbe_cached_solution_planner.cpp
index f298139b7e4..be45869f05c 100644
--- a/src/mongo/db/query/sbe_cached_solution_planner.cpp
+++ b/src/mongo/db/query/sbe_cached_solution_planner.cpp
@@ -187,7 +187,7 @@ CandidatePlans CachedSolutionPlanner::replan(bool shouldCache, std::string reaso
QueryPlannerParams plannerParams;
plannerParams.options = _queryParams.options;
- fillOutPlannerParams(_opCtx, mainColl, &_cq, &plannerParams);
+ fillOutPlannerParams(_opCtx, _collections, &_cq, &plannerParams);
// Use the query planning module to plan the whole query.
auto statusWithMultiPlanSolns = QueryPlanner::plan(_cq, plannerParams);
auto solutions = uassertStatusOK(std::move(statusWithMultiPlanSolns));