diff options
author | Ruoxin Xu <ruoxin.xu@mongodb.com> | 2022-01-17 18:13:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-17 18:39:52 +0000 |
commit | a29b0a6f075bb05a1a87927508edd31656a6a15c (patch) | |
tree | 6111105c737e775d74841f7775a6abee9f483db4 /src/mongo/db/query/plan_explainer_factory.cpp | |
parent | 59d341f677f355939c6f4e8e9934ea1de700c1f7 (diff) | |
download | mongo-a29b0a6f075bb05a1a87927508edd31656a6a15c.tar.gz |
SERVER-59682 Recover SBE plans from the new plan cache
Diffstat (limited to 'src/mongo/db/query/plan_explainer_factory.cpp')
-rw-r--r-- | src/mongo/db/query/plan_explainer_factory.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/query/plan_explainer_factory.cpp b/src/mongo/db/query/plan_explainer_factory.cpp index 74d0c1dfd3d..ef4858e1f7c 100644 --- a/src/mongo/db/query/plan_explainer_factory.cpp +++ b/src/mongo/db/query/plan_explainer_factory.cpp @@ -31,6 +31,7 @@ #include "mongo/db/query/plan_explainer_factory.h" +#include "mongo/db/exec/plan_cache_util.h" #include "mongo/db/query/plan_explainer_impl.h" #include "mongo/db/query/plan_explainer_sbe.h" @@ -54,7 +55,29 @@ std::unique_ptr<PlanExplainer> make(sbe::PlanStage* root, const QuerySolution* solution, std::vector<sbe::plan_ranker::CandidatePlan> rejectedCandidates, bool isMultiPlan) { + // Pre-compute Debugging info for explain use. + auto debugInfoSBE = std::make_unique<plan_cache_debug_info::DebugInfoSBE>( + plan_cache_util::buildDebugInfo(solution)); return std::make_unique<PlanExplainerSBE>( - root, data, solution, std::move(rejectedCandidates), isMultiPlan); + root, data, solution, std::move(rejectedCandidates), isMultiPlan, std::move(debugInfoSBE)); +} + +std::unique_ptr<PlanExplainer> make( + sbe::PlanStage* root, + const stage_builder::PlanStageData* data, + const QuerySolution* solution, + std::vector<sbe::plan_ranker::CandidatePlan> rejectedCandidates, + bool isMultiPlan, + std::unique_ptr<plan_cache_debug_info::DebugInfoSBE> debugInfoSBE) { + // TODO SERVER-61314: Consider invariant(debugInfoSBE) as we may not need to create a + // DebugInfoSBE from QuerySolution after the feature flag is removed. We currently need it + // because debugInfoSBE can be null if the plan was recovered from the classic plan cache. + if (!debugInfoSBE) { + debugInfoSBE = std::make_unique<plan_cache_debug_info::DebugInfoSBE>( + plan_cache_util::buildDebugInfo(solution)); + } + + return std::make_unique<PlanExplainerSBE>( + root, data, solution, std::move(rejectedCandidates), isMultiPlan, std::move(debugInfoSBE)); } } // namespace mongo::plan_explainer_factory |