summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/mr.cpp5
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp10
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index d0066e7e066..27edf464286 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1465,6 +1465,11 @@ public:
if (config.limit && numInputs >= config.limit)
break;
}
+
+ // Record the indexes used by the PlanExecutor.
+ PlanSummaryStats stats;
+ Explain::getSummaryStats(*exec, &stats);
+ coll->infoCache()->notifyOfQuery(txn, stats.indexesUsed);
}
pm.finished();
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index ada7e33e311..f8bbf2fc81c 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -228,6 +228,16 @@ public:
PipelineD::prepareCursorSource(txn, collection, pPipeline, pCtx);
pPipeline->stitch();
+ if (collection && input) {
+ // Record the indexes used by the input executor. Retrieval of summary stats for a
+ // PlanExecutor is normally done post execution. DocumentSourceCursor however will
+ // destroy the input PlanExecutor once the result set has been exhausted. For
+ // that reason we need to collect the indexes used prior to plan execution.
+ PlanSummaryStats stats;
+ Explain::getSummaryStats(*input, &stats);
+ collection->infoCache()->notifyOfQuery(txn, stats.indexesUsed);
+ }
+
// Create the PlanExecutor which returns results from the pipeline. The WorkingSet
// ('ws') and the PipelineProxyStage ('proxy') will be owned by the created
// PlanExecutor.