diff options
author | Hana Pearlman <hana.pearlman@mongodb.com> | 2021-04-16 14:45:39 +0000 |
---|---|---|
committer | Hana Pearlman <hana.pearlman@mongodb.com> | 2021-04-16 14:45:39 +0000 |
commit | 5125c021566323508211b2e54c2de70b985db1d8 (patch) | |
tree | 3410e13cf94d4cc068a3ff714b0326043cfbffbc | |
parent | f071c009b5b8e45e4c92fd72fc6d3f5370e5b971 (diff) | |
download | mongo-5125c021566323508211b2e54c2de70b985db1d8.tar.gz |
Don't use set intersection
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 13 |
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); |