summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-02-12 13:54:11 -0500
committerDavid Storch <david.storch@10gen.com>2015-02-20 10:26:12 -0500
commitbe2f8584a96d44a0c82b40b472dbc92ac10508f9 (patch)
treef91a691cfbb60617ee092ad5c9cddbb4ac927648 /src
parentae18bbec33db1c4bf57d328505474eb7bba517df (diff)
downloadmongo-be2f8584a96d44a0c82b40b472dbc92ac10508f9.tar.gz
SERVER-4494 add index version to explain output
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/exec/count_scan.cpp1
-rw-r--r--src/mongo/db/exec/distinct_scan.cpp5
-rw-r--r--src/mongo/db/exec/distinct_scan.h2
-rw-r--r--src/mongo/db/exec/index_scan.cpp1
-rw-r--r--src/mongo/db/exec/plan_stats.h15
-rw-r--r--src/mongo/db/query/explain.cpp6
-rw-r--r--src/mongo/db/query/planner_analysis.cpp2
-rw-r--r--src/mongo/db/query/query_solution.h2
-rw-r--r--src/mongo/db/query/stage_builder.cpp2
-rw-r--r--src/mongo/db/query/stage_types.h4
10 files changed, 27 insertions, 13 deletions
diff --git a/src/mongo/db/exec/count_scan.cpp b/src/mongo/db/exec/count_scan.cpp
index 4283a4e57a4..24134ecacee 100644
--- a/src/mongo/db/exec/count_scan.cpp
+++ b/src/mongo/db/exec/count_scan.cpp
@@ -56,6 +56,7 @@ namespace mongo {
_specificStats.keyPattern = _params.descriptor->keyPattern();
_specificStats.indexName = _params.descriptor->indexName();
_specificStats.isMultiKey = _params.descriptor->isMultikey(txn);
+ _specificStats.indexVersion = _params.descriptor->version();
}
void CountScan::initIndexCursor() {
diff --git a/src/mongo/db/exec/distinct_scan.cpp b/src/mongo/db/exec/distinct_scan.cpp
index 1a5468a72b1..c92c5af2db6 100644
--- a/src/mongo/db/exec/distinct_scan.cpp
+++ b/src/mongo/db/exec/distinct_scan.cpp
@@ -41,7 +41,7 @@ namespace mongo {
using std::vector;
// static
- const char* DistinctScan::kStageType = "DISTINCT";
+ const char* DistinctScan::kStageType = "DISTINCT_SCAN";
DistinctScan::DistinctScan(OperationContext* txn, const DistinctParams& params, WorkingSet* workingSet)
: _txn(txn),
@@ -54,6 +54,7 @@ namespace mongo {
_commonStats(kStageType) {
_specificStats.keyPattern = _params.descriptor->keyPattern();
_specificStats.indexName = _params.descriptor->indexName();
+ _specificStats.indexVersion = _params.descriptor->version();
}
void DistinctScan::initIndexCursor() {
@@ -255,7 +256,7 @@ namespace mongo {
PlanStageStats* DistinctScan::getStats() {
_commonStats.isEOF = isEOF();
- auto_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_DISTINCT));
+ auto_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_DISTINCT_SCAN));
ret->specific.reset(new DistinctScanStats(_specificStats));
return ret.release();
}
diff --git a/src/mongo/db/exec/distinct_scan.h b/src/mongo/db/exec/distinct_scan.h
index 9ee1d084f5c..f22508302c4 100644
--- a/src/mongo/db/exec/distinct_scan.h
+++ b/src/mongo/db/exec/distinct_scan.h
@@ -108,7 +108,7 @@ namespace mongo {
virtual std::vector<PlanStage*> getChildren() const;
- virtual StageType stageType() const { return STAGE_DISTINCT; }
+ virtual StageType stageType() const { return STAGE_DISTINCT_SCAN; }
virtual PlanStageStats* getStats();
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index 7a302365c9f..1e12623ad7c 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -84,6 +84,7 @@ namespace mongo {
_specificStats.keyPattern = _keyPattern;
_specificStats.indexName = _params.descriptor->indexName();
_specificStats.isMultiKey = _params.descriptor->isMultikey(_txn);
+ _specificStats.indexVersion = _params.descriptor->version();
}
void IndexScan::initIndexScan() {
diff --git a/src/mongo/db/exec/plan_stats.h b/src/mongo/db/exec/plan_stats.h
index 3238055d9f3..6e1069f1609 100644
--- a/src/mongo/db/exec/plan_stats.h
+++ b/src/mongo/db/exec/plan_stats.h
@@ -243,7 +243,8 @@ namespace mongo {
};
struct CountScanStats : public SpecificStats {
- CountScanStats() : isMultiKey(false),
+ CountScanStats() : indexVersion(0),
+ isMultiKey(false),
keysExamined(0) { }
virtual ~CountScanStats() { }
@@ -259,6 +260,8 @@ namespace mongo {
BSONObj keyPattern;
+ int indexVersion;
+
bool isMultiKey;
size_t keysExamined;
@@ -280,7 +283,7 @@ namespace mongo {
};
struct DistinctScanStats : public SpecificStats {
- DistinctScanStats() : keysExamined(0) { }
+ DistinctScanStats() : keysExamined(0), indexVersion(0) { }
virtual SpecificStats* clone() const {
DistinctScanStats* specific = new DistinctScanStats(*this);
@@ -294,6 +297,8 @@ namespace mongo {
std::string indexName;
BSONObj keyPattern;
+
+ int indexVersion;
};
struct FetchStats : public SpecificStats {
@@ -356,7 +361,9 @@ namespace mongo {
};
struct IndexScanStats : public SpecificStats {
- IndexScanStats() : isMultiKey(false),
+ IndexScanStats() : indexVersion(0),
+ direction(1),
+ isMultiKey(false),
yieldMovedCursor(0),
dupsTested(0),
dupsDropped(0),
@@ -382,6 +389,8 @@ namespace mongo {
BSONObj keyPattern;
+ int indexVersion;
+
// A BSON (opaque, ie. hands off other than toString() it) representation of the bounds
// used.
BSONObj indexBounds;
diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp
index 6247040e267..9274ce3b1de 100644
--- a/src/mongo/db/query/explain.cpp
+++ b/src/mongo/db/query/explain.cpp
@@ -121,7 +121,7 @@ namespace {
const CountScanStats* spec = static_cast<const CountScanStats*>(specific);
return spec->keysExamined;
}
- else if (STAGE_DISTINCT == type) {
+ else if (STAGE_DISTINCT_SCAN == type) {
const DistinctScanStats* spec = static_cast<const DistinctScanStats*>(specific);
return spec->keysExamined;
}
@@ -173,7 +173,7 @@ namespace {
const CountScanStats* spec = static_cast<const CountScanStats*>(specific);
ss << " " << spec->keyPattern;
}
- else if (STAGE_DISTINCT == stage->stageType()) {
+ else if (STAGE_DISTINCT_SCAN == stage->stageType()) {
const DistinctScanStats* spec = static_cast<const DistinctScanStats*>(specific);
ss << " " << spec->keyPattern;
}
@@ -291,6 +291,7 @@ namespace mongo {
bob->append("keyPattern", spec->keyPattern);
bob->append("indexName", spec->indexName);
bob->appendBool("isMultiKey", spec->isMultiKey);
+ bob->append("indexVersion", spec->indexVersion);
}
else if (STAGE_DELETE == stats.stageType) {
DeleteStats* spec = static_cast<DeleteStats*>(stats.specific.get());
@@ -345,6 +346,7 @@ namespace mongo {
bob->append("keyPattern", spec->keyPattern);
bob->append("indexName", spec->indexName);
bob->appendBool("isMultiKey", spec->isMultiKey);
+ bob->append("indexVersion", spec->indexVersion);
bob->append("direction", spec->direction > 0 ? "forward" : "backward");
if ((topLevelBob->len() + spec->indexBounds.objsize()) > kMaxStatsBSONSize) {
diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp
index 24f5af7279b..1d8cac44090 100644
--- a/src/mongo/db/query/planner_analysis.cpp
+++ b/src/mongo/db/query/planner_analysis.cpp
@@ -693,7 +693,7 @@ namespace mongo {
coveredKeyObj = ixn->indexKeyPattern;
QLOG() << "PROJECTION: covered via IXSCAN, using COVERED fast path";
}
- else if (STAGE_DISTINCT == leafNodes[0]->getType()) {
+ else if (STAGE_DISTINCT_SCAN == leafNodes[0]->getType()) {
projType = ProjectionNode::COVERED_ONE_INDEX;
DistinctNode* dn = static_cast<DistinctNode*>(leafNodes[0]);
coveredKeyObj = dn->indexKeyPattern;
diff --git a/src/mongo/db/query/query_solution.h b/src/mongo/db/query/query_solution.h
index 6a49beb6edc..544d911c9eb 100644
--- a/src/mongo/db/query/query_solution.h
+++ b/src/mongo/db/query/query_solution.h
@@ -678,7 +678,7 @@ namespace mongo {
DistinctNode() { }
virtual ~DistinctNode() { }
- virtual StageType getType() const { return STAGE_DISTINCT; }
+ virtual StageType getType() const { return STAGE_DISTINCT_SCAN; }
virtual void appendToString(mongoutils::str::stream* ss, int indent) const;
// This stage is created "on top" of normal planning and as such the properties
diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp
index 097b4f71e61..0cdd4e03459 100644
--- a/src/mongo/db/query/stage_builder.cpp
+++ b/src/mongo/db/query/stage_builder.cpp
@@ -286,7 +286,7 @@ namespace mongo {
if (NULL == childStage) { return NULL; }
return new KeepMutationsStage(km->filter.get(), ws, childStage);
}
- else if (STAGE_DISTINCT == root->getType()) {
+ else if (STAGE_DISTINCT_SCAN == root->getType()) {
const DistinctNode* dn = static_cast<const DistinctNode*>(root);
if (NULL == collection) {
diff --git a/src/mongo/db/query/stage_types.h b/src/mongo/db/query/stage_types.h
index 83574b4292d..273da805283 100644
--- a/src/mongo/db/query/stage_types.h
+++ b/src/mongo/db/query/stage_types.h
@@ -51,8 +51,8 @@ namespace mongo {
STAGE_DELETE,
// If we're running a distinct, we only care about one value for each key. The distinct
- // stage is an ixscan with some key-skipping behvaior that only distinct uses.
- STAGE_DISTINCT,
+ // scan stage is an ixscan with some key-skipping behvaior that only distinct uses.
+ STAGE_DISTINCT_SCAN,
// Dummy stage used for receiving notifications of deletions during chunk migration.
STAGE_NOTIFY_DELETE,