summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2014-03-03 14:18:06 -0500
committerBenety Goh <benety@mongodb.com>2014-03-03 16:21:10 -0500
commitcd1cdfcce54d4c0e06aed61b214c383edcae4b02 (patch)
tree427a9f285e961744d00f03de900774a189fe4c73 /src
parentf8534ae0d6c4e252d169c5bcf42f42cf6518ee7d (diff)
downloadmongo-cd1cdfcce54d4c0e06aed61b214c383edcae4b02.tar.gz
SERVER-12935 override OR child indexOnly when explaining non-covered queries
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/query/explain_plan.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/query/explain_plan.cpp b/src/mongo/db/query/explain_plan.cpp
index 85a64659316..2e9140790f3 100644
--- a/src/mongo/db/query/explain_plan.cpp
+++ b/src/mongo/db/query/explain_plan.cpp
@@ -204,6 +204,18 @@ namespace mongo {
TypeExplain* childExplain = NULL;
explainPlan(**it, &childExplain, false /* no full details */);
if (childExplain) {
+ // Override child's indexOnly value if we have a non-covered
+ // query (implied by a FETCH stage).
+ //
+ // As we run explain on each child, explainPlan() sets indexOnly
+ // based only on the information in each child. This does not
+ // consider the possibility of a FETCH stage above the OR/MERGE_SORT
+ // stage, in which case the child's indexOnly may be erroneously set
+ // to true.
+ if (!covered && childExplain->isIndexOnlySet()) {
+ childExplain->setIndexOnly(false);
+ }
+
// 'res' takes ownership of 'childExplain'.
res->addToClauses(childExplain);
nScanned += childExplain->getNScanned();