diff options
author | David Storch <david.storch@10gen.com> | 2017-02-10 11:52:18 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2017-03-13 09:46:14 -0400 |
commit | 82b16740f8a66093b453a73a04b3b9bd00e5d7a0 (patch) | |
tree | 62d156fc9676526ecbea19cd03ef7a293579c4df /src/mongo/dbtests/documentsourcetests.cpp | |
parent | 73f9e8b8a8422becf8694fe3d82c0e647dc71189 (diff) | |
download | mongo-82b16740f8a66093b453a73a04b3b9bd00e5d7a0.tar.gz |
SERVER-19758 add support for "executionStats" and "allPlansExecution" to agg explain
Like other explainable commands, aggregate can now be
explained using the explain command, e.g.
db.runCommand({explain: {aggregate: ...}, verbosity:
"executionStats"}). The existing explain:true flag
corresponds to "queryPlanner" mode and is still supported.
However, explain:true cannot be specified when explaining
aggregate via the explain command.
Additional execution information is provided only in the
$cursor section of the aggregation explain output. Having
aggregation stages themselves track and report execution
info is further work.
Diffstat (limited to 'src/mongo/dbtests/documentsourcetests.cpp')
-rw-r--r-- | src/mongo/dbtests/documentsourcetests.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp index a5add096d27..58df14b77b4 100644 --- a/src/mongo/dbtests/documentsourcetests.cpp +++ b/src/mongo/dbtests/documentsourcetests.cpp @@ -310,6 +310,40 @@ public: } }; +class SerializationRespectsExplainModes : public Base { +public: + void run() { + createSource(); + + { + // Nothing serialized when no explain mode specified. + auto explainResult = source()->serialize(); + ASSERT_TRUE(explainResult.missing()); + } + + { + auto explainResult = source()->serialize(ExplainOptions::Verbosity::kQueryPlanner); + ASSERT_FALSE(explainResult["$cursor"]["queryPlanner"].missing()); + ASSERT_TRUE(explainResult["$cursor"]["executionStats"].missing()); + } + + { + auto explainResult = source()->serialize(ExplainOptions::Verbosity::kExecStats); + ASSERT_FALSE(explainResult["$cursor"]["queryPlanner"].missing()); + ASSERT_FALSE(explainResult["$cursor"]["executionStats"].missing()); + ASSERT_TRUE(explainResult["$cursor"]["executionStats"]["allPlansExecution"].missing()); + } + + { + auto explainResult = + source()->serialize(ExplainOptions::Verbosity::kExecAllPlans).getDocument(); + ASSERT_FALSE(explainResult["$cursor"]["queryPlanner"].missing()); + ASSERT_FALSE(explainResult["$cursor"]["executionStats"].missing()); + ASSERT_FALSE(explainResult["$cursor"]["executionStats"]["allPlansExecution"].missing()); + } + } +}; + } // namespace DocumentSourceCursor class All : public Suite { @@ -325,6 +359,7 @@ public: add<DocumentSourceCursor::IndexScanProvidesSortOnKeys>(); add<DocumentSourceCursor::ReverseIndexScanProvidesSort>(); add<DocumentSourceCursor::CompoundIndexScanProvidesMultipleSorts>(); + add<DocumentSourceCursor::SerializationRespectsExplainModes>(); } }; |