summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2022-01-27 14:53:05 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-27 15:53:17 +0000
commitf27f088ecf14825a2ae9cedb2c13093287ded84a (patch)
treeb38f12dcf2e9ad7a5c9e2a0b8546ff0cd69e6f2d /src/mongo/db/exec
parent2891359b151883d41ceb3b79d769867462b79e89 (diff)
downloadmongo-f27f088ecf14825a2ae9cedb2c13093287ded84a.tar.gz
SERVER-62981 Make SBE multi-planner trial period length independent of collection size
This patch changes the 'internalQueryPlanEvaluationCollFraction' knob to apply only to the classic engine. It introduces a separate knob, 'internalQueryPlanEvaluationCollFractionSbe', which applies only to the SBE engine. The SBE knob has a default of 0, while the classic engine retains its default of 0.3. This ensures that by default, no candidate plan will ever do more than 10,000 storage reads during SBE multi-planning.
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/multi_plan.cpp3
-rw-r--r--src/mongo/db/exec/trial_period_utils.cpp10
-rw-r--r--src/mongo/db/exec/trial_period_utils.h7
3 files changed, 11 insertions, 9 deletions
diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp
index 7dfb6ffc5d7..892d05cb5ca 100644
--- a/src/mongo/db/exec/multi_plan.cpp
+++ b/src/mongo/db/exec/multi_plan.cpp
@@ -163,7 +163,8 @@ Status MultiPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
// make sense.
auto optTimer = getOptTimer();
- size_t numWorks = trial_period::getTrialPeriodMaxWorks(opCtx(), collection());
+ size_t numWorks = trial_period::getTrialPeriodMaxWorks(
+ opCtx(), collection(), internalQueryPlanEvaluationCollFraction.load());
size_t numResults = trial_period::getTrialPeriodNumToReturn(*_query);
try {
diff --git a/src/mongo/db/exec/trial_period_utils.cpp b/src/mongo/db/exec/trial_period_utils.cpp
index 3ed27ad751c..2472885c7ed 100644
--- a/src/mongo/db/exec/trial_period_utils.cpp
+++ b/src/mongo/db/exec/trial_period_utils.cpp
@@ -34,17 +34,15 @@
#include "mongo/db/catalog/collection.h"
namespace mongo::trial_period {
-size_t getTrialPeriodMaxWorks(OperationContext* opCtx, const CollectionPtr& collection) {
+size_t getTrialPeriodMaxWorks(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ double collFraction) {
// Run each plan some number of times. This number is at least as great as
// 'internalQueryPlanEvaluationWorks', but may be larger for big collections.
size_t numWorks = internalQueryPlanEvaluationWorks.load();
if (collection) {
- // For large collections, the number of works is set to be this fraction of the collection
- // size.
- double fraction = internalQueryPlanEvaluationCollFraction;
-
numWorks = std::max(static_cast<size_t>(internalQueryPlanEvaluationWorks.load()),
- static_cast<size_t>(fraction * collection->numRecords(opCtx)));
+ static_cast<size_t>(collFraction * collection->numRecords(opCtx)));
}
return numWorks;
diff --git a/src/mongo/db/exec/trial_period_utils.h b/src/mongo/db/exec/trial_period_utils.h
index 609d5f3b484..53a9c91a889 100644
--- a/src/mongo/db/exec/trial_period_utils.h
+++ b/src/mongo/db/exec/trial_period_utils.h
@@ -39,9 +39,12 @@ namespace trial_period {
/**
* Returns the number of times that we are willing to work a plan during a trial period.
*
- * Calculated based on a fixed query knob and the size of the collection.
+ * Calculated based on a fixed query knob and the size of the collection multiplied by
+ * 'collFraction'.
*/
-size_t getTrialPeriodMaxWorks(OperationContext* opCtx, const CollectionPtr& collection);
+size_t getTrialPeriodMaxWorks(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ double collFraction);
/**
* Returns the max number of documents which we should allow any plan to return during the