summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2022-02-09 17:49:14 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-09 19:06:01 +0000
commita94caa502cf94fa6c8fcfea7283d7eaf3bd55ad5 (patch)
treeb9190c0408050244ab5a31e792ac5bb5422a63ff /src/mongo/db/exec
parent32b042a2ed38d8a3f056b862cf6b13b36fb7ee4c (diff)
SERVER-63102 Introduce internalQueryPlanEvaluationWorksSber5.3.0-alpha3
The 'internalQueryPlanEvaluationWorks' parameter now only affects the classic engine. The newly added parameter has similar behavior, but applies only to queries using SBE.
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/multi_plan.cpp7
-rw-r--r--src/mongo/db/exec/trial_period_utils.cpp9
-rw-r--r--src/mongo/db/exec/trial_period_utils.h7
3 files changed, 14 insertions, 9 deletions
diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp
index 892d05cb5ca..96aaf4ca52d 100644
--- a/src/mongo/db/exec/multi_plan.cpp
+++ b/src/mongo/db/exec/multi_plan.cpp
@@ -163,8 +163,11 @@ Status MultiPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
// make sense.
auto optTimer = getOptTimer();
- size_t numWorks = trial_period::getTrialPeriodMaxWorks(
- opCtx(), collection(), internalQueryPlanEvaluationCollFraction.load());
+ const size_t numWorks =
+ trial_period::getTrialPeriodMaxWorks(opCtx(),
+ collection(),
+ internalQueryPlanEvaluationWorks.load(),
+ 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 2472885c7ed..b158f297b47 100644
--- a/src/mongo/db/exec/trial_period_utils.cpp
+++ b/src/mongo/db/exec/trial_period_utils.cpp
@@ -36,13 +36,12 @@
namespace mongo::trial_period {
size_t getTrialPeriodMaxWorks(OperationContext* opCtx,
const CollectionPtr& collection,
+ int maxWorksParam,
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();
+ size_t numWorks = static_cast<size_t>(maxWorksParam);
if (collection) {
- numWorks = std::max(static_cast<size_t>(internalQueryPlanEvaluationWorks.load()),
- static_cast<size_t>(collFraction * collection->numRecords(opCtx)));
+ numWorks =
+ std::max(numWorks, 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 53a9c91a889..f8e4d4a725f 100644
--- a/src/mongo/db/exec/trial_period_utils.h
+++ b/src/mongo/db/exec/trial_period_utils.h
@@ -39,11 +39,14 @@ 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 multiplied by
- * 'collFraction'.
+ * Calculated with the following formula, where "|collection|" denotes the approximate number of
+ * documents in the collection:
+ *
+ * max(maxWorksParam, collFraction * |collection|)
*/
size_t getTrialPeriodMaxWorks(OperationContext* opCtx,
const CollectionPtr& collection,
+ int maxWorksParam,
double collFraction);
/**