diff options
author | Justin Zhang <justin.zhang@mongodb.com> | 2022-08-19 19:33:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-19 20:53:08 +0000 |
commit | 0ae6bba3c1483a309640e60ba5fb80f45b16ea67 (patch) | |
tree | f81d9f62f11a86a7154dc6c740bf01b7e8959e39 /src/mongo/db/query/collection_query_info.cpp | |
parent | bcebd12f2e6492eef7f609d8b234f81e92c2f683 (diff) | |
download | mongo-0ae6bba3c1483a309640e60ba5fb80f45b16ea67.tar.gz |
SERVER-67140 Change query planner to determine column index eligibility based on field projection
Diffstat (limited to 'src/mongo/db/query/collection_query_info.cpp')
-rw-r--r-- | src/mongo/db/query/collection_query_info.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/query/collection_query_info.cpp b/src/mongo/db/query/collection_query_info.cpp index a0b4fe3cd36..55261978b21 100644 --- a/src/mongo/db/query/collection_query_info.cpp +++ b/src/mongo/db/query/collection_query_info.cpp @@ -42,6 +42,7 @@ #include "mongo/db/exec/projection_executor.h" #include "mongo/db/exec/projection_executor_utils.h" #include "mongo/db/fts/fts_spec.h" +#include "mongo/db/index/columns_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/index/wildcard_access_method.h" #include "mongo/db/query/classic_plan_cache.h" @@ -127,10 +128,14 @@ void CollectionQueryInfo::computeIndexKeys(OperationContext* opCtx, const Collec const IndexDescriptor* descriptor = entry->descriptor(); const IndexAccessMethod* iam = entry->accessMethod(); - if (descriptor->getAccessMethodName() == IndexNames::WILDCARD) { + if (bool isWildcard = (descriptor->getAccessMethodName() == IndexNames::WILDCARD); + isWildcard || descriptor->getAccessMethodName() == IndexNames::COLUMN) { // Obtain the projection used by the $** index's key generator. - const auto* pathProj = - static_cast<const WildcardAccessMethod*>(iam)->getWildcardProjection(); + const auto* pathProj = isWildcard + ? static_cast<const IndexPathProjection*>( + static_cast<const WildcardAccessMethod*>(iam)->getWildcardProjection()) + : static_cast<const IndexPathProjection*>( + static_cast<const ColumnStoreAccessMethod*>(iam)->getColumnstoreProjection()); // If the projection is an exclusion, then we must check the new document's keys on all // updates, since we do not exhaustively know the set of paths to be indexed. if (pathProj->exec()->getType() == @@ -145,8 +150,6 @@ void CollectionQueryInfo::computeIndexKeys(OperationContext* opCtx, const Collec _indexedPaths.addPath(path); } } - } else if (descriptor->getAccessMethodName() == IndexNames::COLUMN) { - _indexedPaths.allPathsIndexed(); } else if (descriptor->getAccessMethodName() == IndexNames::TEXT) { fts::FTSSpec ftsSpec(descriptor->infoObj()); |