diff options
author | Irina Yatsenko <irina.yatsenko@mongodb.com> | 2022-02-10 18:54:13 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-10 21:20:17 +0000 |
commit | 80224491b2f8341930d6b1f45ff935367ee2538f (patch) | |
tree | 7b33769f514a9865b3425448825fc237fecfada2 /src/mongo/db/query/sbe_cached_solution_planner.cpp | |
parent | 26292d02824c0e804eea510302019add57b6cccc (diff) | |
download | mongo-80224491b2f8341930d6b1f45ff935367ee2538f.tar.gz |
SERVER-58426 Implement $lookup planning logic
Co-authored-by: Mihai Andrei <mihai.andrei@mongodb.com>
Diffstat (limited to 'src/mongo/db/query/sbe_cached_solution_planner.cpp')
-rw-r--r-- | src/mongo/db/query/sbe_cached_solution_planner.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/query/sbe_cached_solution_planner.cpp b/src/mongo/db/query/sbe_cached_solution_planner.cpp index d0fd8db0b81..61a2df9f6db 100644 --- a/src/mongo/db/query/sbe_cached_solution_planner.cpp +++ b/src/mongo/db/query/sbe_cached_solution_planner.cpp @@ -54,9 +54,10 @@ CandidatePlans CachedSolutionPlanner::plan( // during multiplanning even though multiplanning ran trials of pre-extended plans. if (!_cq.pipeline().empty()) { _yieldPolicy->clearRegisteredPlans(); - solutions[0] = QueryPlanner::extendWithAggPipeline(_cq, std::move(solutions[0])); + solutions[0] = QueryPlanner::extendWithAggPipeline( + _cq, std::move(solutions[0]), _queryParams.secondaryCollectionsInfo); roots[0] = stage_builder::buildSlotBasedExecutableTree( - _opCtx, _collection, _cq, *solutions[0], _yieldPolicy); + _opCtx, _collections, _cq, *solutions[0], _yieldPolicy); } const size_t maxReadsBeforeReplan = internalQueryCacheEvictionRatio * _decisionReads; @@ -172,16 +173,17 @@ CandidatePlans CachedSolutionPlanner::replan(bool shouldCache, std::string reaso // Therefore, if any of the collection's indexes have been dropped, the query should fail with // a 'QueryPlanKilled' error. _indexExistenceChecker.check(); + const auto& mainColl = _collections.getMainCollection(); if (shouldCache) { // Deactivate the current cache entry. - auto cache = CollectionQueryInfo::get(_collection).getPlanCache(); - cache->deactivate(plan_cache_key_factory::make<mongo::PlanCacheKey>(_cq, _collection)); + auto cache = CollectionQueryInfo::get(mainColl).getPlanCache(); + cache->deactivate(plan_cache_key_factory::make<mongo::PlanCacheKey>(_cq, mainColl)); } auto buildExecutableTree = [&](const QuerySolution& sol) { auto [root, data] = stage_builder::buildSlotBasedExecutableTree( - _opCtx, _collection, _cq, sol, _yieldPolicy); + _opCtx, _collections, _cq, sol, _yieldPolicy); data.replanReason.emplace(reason); return std::make_pair(std::move(root), std::move(data)); }; @@ -225,7 +227,7 @@ CandidatePlans CachedSolutionPlanner::replan(bool shouldCache, std::string reaso const auto cachingMode = shouldCache ? PlanCachingMode::AlwaysCache : PlanCachingMode::NeverCache; - MultiPlanner multiPlanner{_opCtx, _collection, _cq, cachingMode, _yieldPolicy}; + MultiPlanner multiPlanner{_opCtx, _collections, _cq, _queryParams, cachingMode, _yieldPolicy}; auto&& [candidates, winnerIdx] = multiPlanner.plan(std::move(solutions), std::move(roots)); auto explainer = plan_explainer_factory::make(candidates[winnerIdx].root.get(), &candidates[winnerIdx].data, |