summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 13:43:02 +0000
committerHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 13:43:11 +0000
commitf37dc54f9f5b2e44aaeecb42f18ce990d680501f (patch)
tree364b796951e4191c218cad85b6321d2b1e27bfd5
parent2f99cbab75fa49374365ab29647661bd609f905e (diff)
downloadmongo-f37dc54f9f5b2e44aaeecb42f18ce990d680501f.tar.gz
Get multikey info for all wildcard index fields being queried
-rw-r--r--src/mongo/db/query/get_executor.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index c4536c8b654..a756bb5c4eb 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -209,11 +209,19 @@ IndexEntry indexEntryFromIndexCatalogEntry(OperationContext* opCtx,
if (canonicalQuery) {
stdx::unordered_set<std::string> fields;
QueryPlannerIXSelect::getFields(canonicalQuery->root(), &fields);
- const auto projectedFields = projection_executor_utils::applyProjectionToFields(
+ auto projectedFields = projection_executor_utils::applyProjectionToFields(
wildcardProjection->exec(), fields);
- multikeyPathSet =
- getWildcardMultikeyPathSet(wam, opCtx, projectedFields, &mkAccessStats);
+ // For a compound wildcard index, we also want to get the multikey information
+ // for (non-wildcard) fields in the index which are being queried.
+ auto indexKeys = wam->getKeyPattern().getFieldNames<std::set<std::string>>();
+ std::set_intersection(fields.begin(),
+ fields.end(),
+ indexKeys.begin(),
+ indexKeys.end(),
+ std::inserter(projectedFields, projectedFields.begin()));
+
+ multikeyPathSet = getWildcardMultikeyPathSet(wam, opCtx, fields, &mkAccessStats);
} else {
multikeyPathSet = getWildcardMultikeyPathSet(wam, opCtx, &mkAccessStats);
}