@@ -1425,33 +1425,6 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getSlotBasedExe
14251425 false /* generatedByBonsai */ );
14261426} // getSlotBasedExecutor
14271427
1428- /* *
1429- * Checks if the result of query planning is SBE compatible. If any of the query solutions in
1430- * 'planningResult' cannot currently be compiled to an SBE plan via the SBE stage builders, then we
1431- * will fall back to the classic engine.
1432- */
1433- bool shouldPlanningResultUseSbe (const SlotBasedPrepareExecutionResult& planningResult) {
1434- // If we have an entry in the SBE plan cache, then we can use SBE.
1435- if (planningResult.isRecoveredFromPlanCache ()) {
1436- return true ;
1437- }
1438-
1439- const auto & solutions = planningResult.solutions ();
1440- if (solutions.empty ()) {
1441- // Query needs subplanning (plans are generated later, we don't have access yet). We can
1442- // proceed with using SBE in this case.
1443- invariant (planningResult.needsSubplanning ());
1444- return true ;
1445- }
1446-
1447- // Check that all query solutions are SBE compatible.
1448- return std::all_of (solutions.begin (), solutions.end (), [](const auto & solution) {
1449- // We must have a solution, otherwise we would have early exited.
1450- invariant (solution->root ());
1451- return isQueryPlanSbeCompatible (solution.get ());
1452- });
1453- }
1454-
14551428/* *
14561429 * Function which returns true if 'cq' uses features that are currently supported in SBE without
14571430 * 'featureFlagSbeFull' being set; false otherwise.
@@ -1518,9 +1491,6 @@ attemptToGetSlotBasedExecutor(
15181491 // SBE-compatible query using SBE, even if the query uses features that are not on in SBE by
15191492 // default. Either way, try to construct an SBE plan executor.
15201493 if (canUseRegularSbe || sbeFull) {
1521- // Create the SBE prepare execution helper and initialize the params for the planner. If
1522- // planning results in any 'QuerySolution' which cannot be handled by the SBE stage builder,
1523- // then we will fall back to the classic engine.
15241494 stdx::variant<const Yieldable*, PlanYieldPolicy::YieldThroughAcquisitions> yieldable;
15251495 if (collections.isAcquisition ()) {
15261496 yieldable = PlanYieldPolicy::YieldThroughAcquisitions{};
@@ -1536,24 +1506,22 @@ attemptToGetSlotBasedExecutor(
15361506 return planningResultWithStatus.getStatus ();
15371507 }
15381508
1539- if (shouldPlanningResultUseSbe (*planningResultWithStatus.getValue ())) {
1540- if (extractAndAttachPipelineStages) {
1541- // We know now that we will use SBE, so we need to remove the pushed-down stages
1542- // from the original pipeline object.
1543- extractAndAttachPipelineStages (canonicalQuery.get (), false /* attachOnly */ );
1544- }
1545- auto statusWithExecutor =
1546- getSlotBasedExecutor (opCtx,
1547- collections,
1548- std::move (canonicalQuery),
1549- std::move (sbeYieldPolicy),
1550- plannerParams,
1551- std::move (planningResultWithStatus.getValue ()));
1552- if (statusWithExecutor.isOK ()) {
1553- return std::move (statusWithExecutor.getValue ());
1554- } else {
1555- return statusWithExecutor.getStatus ();
1556- }
1509+ if (extractAndAttachPipelineStages) {
1510+ // Given that we are using SBE, we need to remove the pushed-down stages
1511+ // from the original pipeline object.
1512+ extractAndAttachPipelineStages (canonicalQuery.get (), false /* attachOnly */ );
1513+ }
1514+ auto statusWithExecutor =
1515+ getSlotBasedExecutor (opCtx,
1516+ collections,
1517+ std::move (canonicalQuery),
1518+ std::move (sbeYieldPolicy),
1519+ plannerParams,
1520+ std::move (planningResultWithStatus.getValue ()));
1521+ if (statusWithExecutor.isOK ()) {
1522+ return std::move (statusWithExecutor.getValue ());
1523+ } else {
1524+ return statusWithExecutor.getStatus ();
15571525 }
15581526 }
15591527
0 commit comments