diff options
Diffstat (limited to 'src/mongo/db/query/get_executor.cpp')
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index a9158d333fb..54ade9343eb 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -1035,27 +1035,31 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorUpdate( driver->refreshIndexKeys(&updateIndexData); if (!parsedUpdate->hasParsedQuery()) { - // This is the idhack fast-path for getting a PlanExecutor without doing the work - // to create a CanonicalQuery. - const BSONObj& unparsedQuery = request->getQuery(); - - const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(opCtx); - const bool hasCollectionDefaultCollation = CollatorInterface::collatorsMatch( - parsedUpdate->getCollator(), collection->getDefaultCollator()); - - if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && - request->getProj().isEmpty() && hasCollectionDefaultCollation) { - LOG(2) << "Using idhack: " << redact(unparsedQuery); - - // Working set 'ws' is discarded. InternalPlanner::updateWithIdHack() makes its own - // WorkingSet. - return InternalPlanner::updateWithIdHack(opCtx, - collection, - updateStageParams, - descriptor, - unparsedQuery["_id"].wrap(), - policy); + // Only consider using the idhack if no hint was provided. + if (request->getHint().isEmpty()) { + // This is the idhack fast-path for getting a PlanExecutor without doing the work + // to create a CanonicalQuery. + const BSONObj& unparsedQuery = request->getQuery(); + + const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(opCtx); + + const bool hasCollectionDefaultCollation = CollatorInterface::collatorsMatch( + parsedUpdate->getCollator(), collection->getDefaultCollator()); + + if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && + request->getProj().isEmpty() && hasCollectionDefaultCollation) { + LOG(2) << "Using idhack: " << redact(unparsedQuery); + + // Working set 'ws' is discarded. InternalPlanner::updateWithIdHack() makes its own + // WorkingSet. + return InternalPlanner::updateWithIdHack(opCtx, + collection, + updateStageParams, + descriptor, + unparsedQuery["_id"].wrap(), + policy); + } } // If we're here then we don't have a parsed query, but we're also not eligible for |