summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 14:45:39 +0000
committerHana Pearlman <hana.pearlman@mongodb.com>2021-04-16 14:45:39 +0000
commit5125c021566323508211b2e54c2de70b985db1d8 (patch)
tree3410e13cf94d4cc068a3ff714b0326043cfbffbc
parentf071c009b5b8e45e4c92fd72fc6d3f5370e5b971 (diff)
downloadmongo-5125c021566323508211b2e54c2de70b985db1d8.tar.gz
Don't use set intersection
-rw-r--r--src/mongo/db/query/get_executor.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 36179df5791..ddca2f4a41a 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -214,12 +214,13 @@ IndexEntry indexEntryFromIndexCatalogEntry(OperationContext* opCtx,
// 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()));
+ for (auto& indexElem : wam->getKeyPattern()) {
+ auto indexKey = indexElem.fieldNameStringData();
+ if (fields.contains(indexKey.toString()) && indexKey != "$**" &&
+ !indexKey.endsWith(".$**")) {
+ projectedFields.insert(projectedFields.begin(), indexKey.toString());
+ }
+ }
multikeyPathSet =
getWildcardMultikeyPathSet(wam, opCtx, projectedFields, &mkAccessStats);