summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/cached_plan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/cached_plan.cpp')
-rw-r--r--src/mongo/db/exec/cached_plan.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp
index 9738936f4b7..7f35e28a63d 100644
--- a/src/mongo/db/exec/cached_plan.cpp
+++ b/src/mongo/db/exec/cached_plan.cpp
@@ -147,7 +147,10 @@ Status CachedPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
<< " status: " << redact(statusObj);
const bool shouldCache = false;
- return replan(yieldPolicy, shouldCache);
+ return replan(yieldPolicy,
+ shouldCache,
+ str::stream() << "cached plan returned: "
+ << WorkingSetCommon::toStatusString(statusObj));
} else {
invariant(PlanStage::NEED_TIME == state);
}
@@ -162,7 +165,13 @@ Status CachedPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
<< " plan summary before replan: " << Explain::getPlanSummary(child().get());
const bool shouldCache = true;
- return replan(yieldPolicy, shouldCache);
+ return replan(
+ yieldPolicy,
+ shouldCache,
+ str::stream()
+ << "cached plan was less efficient than expected: expected trial execution to take "
+ << _decisionWorks << " works but it took at least " << maxWorksBeforeReplan
+ << " works");
}
Status CachedPlanStage::tryYield(PlanYieldPolicy* yieldPolicy) {
@@ -179,7 +188,7 @@ Status CachedPlanStage::tryYield(PlanYieldPolicy* yieldPolicy) {
return Status::OK();
}
-Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache) {
+Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache, std::string reason) {
// We're going to start over with a new plan. Clear out info from our old plan.
{
std::queue<WorkingSetID> emptyQueue;
@@ -188,7 +197,7 @@ Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache) {
_ws->clear();
_children.clear();
- _specificStats.replanned = true;
+ _specificStats.replanReason = std::move(reason);
if (shouldCache) {
// Deactivate the current cache entry.