summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorIan Boros <ian.boros@10gen.com>2018-03-29 18:17:20 -0400
committerIan Boros <ian.boros@10gen.com>2018-03-30 11:38:26 -0400
commit82fce7bd6f6e2838ce3ccc72474ff8b8ebe325a0 (patch)
treef818229dd15dd2fc3efa3acd4c50ab8fb0f26f91 /src/mongo/db/query
parent431ef23420797fb0956fae4e3d5149e2224bbaee (diff)
downloadmongo-82fce7bd6f6e2838ce3ccc72474ff8b8ebe325a0.tar.gz
SERVER-3645 make count() with a predicate accurate on sharded clusters
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/get_executor.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index ce5e2b3718e..9bc7c37454f 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -1330,7 +1330,11 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorCount(
opCtx, std::move(ws), std::move(root), request.getNs(), yieldPolicy);
}
- const size_t plannerOptions = QueryPlannerParams::IS_COUNT;
+ size_t plannerOptions = QueryPlannerParams::IS_COUNT;
+ if (ShardingState::get(opCtx)->needCollectionMetadata(opCtx, request.getNs().ns())) {
+ plannerOptions |= QueryPlannerParams::INCLUDE_SHARD_FILTER;
+ }
+
StatusWith<PrepareExecutionResult> executionResult =
prepareExecution(opCtx, collection, ws.get(), std::move(cq), plannerOptions);
if (!executionResult.isOK()) {