summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/projection.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2014-06-11 14:24:20 -0400
committerDavid Storch <david.storch@10gen.com>2014-06-27 09:56:04 -0400
commit1cc6be662ccd83b0341ef1f31f8f4ad30dc69451 (patch)
tree2cdd5f7e473d77685f6f7ca1c6735f75991089a7 /src/mongo/db/exec/projection.cpp
parenta67bddc57c9b8a8d9d13ac30ebe74f9914b0c6d0 (diff)
downloadmongo-1cc6be662ccd83b0341ef1f31f8f4ad30dc69451.tar.gz
SERVER-14097 SERVER-14098 execution-level explain for .find() and .count()
The explain implementation for .find() and .count() is feature complete. To use the .find() implementation, set the enableNewExplain setParameter to true. Count operations are explained through the new explain command, e.g. db.runCommand({explain: {count: "coll", query: {foo: "bar"}}}).
Diffstat (limited to 'src/mongo/db/exec/projection.cpp')
-rw-r--r--src/mongo/db/exec/projection.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp
index 60c0aa221f3..c4c8388462f 100644
--- a/src/mongo/db/exec/projection.cpp
+++ b/src/mongo/db/exec/projection.cpp
@@ -50,6 +50,8 @@ namespace mongo {
_commonStats(kStageType),
_projImpl(params.projImpl) {
+ _projObj = params.projObj;
+
if (ProjectionStageParams::NO_FAST_PATH == _projImpl) {
_exec.reset(new ProjectionExec(params.projObj,
params.fullExpression,
@@ -59,8 +61,6 @@ namespace mongo {
// We shouldn't need the full expression if we're fast-pathing.
invariant(NULL == params.fullExpression);
- _projObj = params.projObj;
-
// Sanity-check the input.
invariant(_projObj.isOwned());
invariant(!_projObj.isEmpty());
@@ -197,6 +197,9 @@ namespace mongo {
PlanStage::StageState ProjectionStage::work(WorkingSetID* out) {
++_commonStats.works;
+ // Adds the amount of time taken by work() to executionTimeMillis.
+ ScopedTimer timer(&_commonStats.executionTimeMillis);
+
WorkingSetID id = WorkingSet::INVALID_ID;
StageState status = _child->work(&id);
@@ -247,11 +250,20 @@ namespace mongo {
_child->invalidate(dl, type);
}
+ vector<PlanStage*> ProjectionStage::getChildren() const {
+ vector<PlanStage*> children;
+ children.push_back(_child.get());
+ return children;
+ }
+
PlanStageStats* ProjectionStage::getStats() {
_commonStats.isEOF = isEOF();
- _specificStats.projObj = _projObj;
auto_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_PROJECTION));
- ret->specific.reset(new ProjectionStats(_specificStats));
+
+ ProjectionStats* projStats = new ProjectionStats(_specificStats);
+ projStats->projObj = _projObj;
+ ret->specific.reset(projStats);
+
ret->children.push_back(_child->getStats());
return ret.release();
}