diff options
Diffstat (limited to 'src/mongo/db/query/get_executor.cpp')
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 6388f5986b0..c9b0db6c5b3 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -783,41 +783,46 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDelete( } if (!parsedDelete->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); - - // Construct delete request collator. - std::unique_ptr<CollatorInterface> collator; - if (!request->getCollation().isEmpty()) { - auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext()) - ->makeFromBSON(request->getCollation()); - if (!statusWithCollator.isOK()) { - return statusWithCollator.getStatus(); + + // 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); + + // Construct delete request collator. + std::unique_ptr<CollatorInterface> collator; + if (!request->getCollation().isEmpty()) { + auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext()) + ->makeFromBSON(request->getCollation()); + if (!statusWithCollator.isOK()) { + return statusWithCollator.getStatus(); + } + collator = std::move(statusWithCollator.getValue()); } - collator = std::move(statusWithCollator.getValue()); - } - const bool hasCollectionDefaultCollation = request->getCollation().isEmpty() || - CollatorInterface::collatorsMatch(collator.get(), collection->getDefaultCollator()); + const bool hasCollectionDefaultCollation = request->getCollation().isEmpty() || + CollatorInterface::collatorsMatch(collator.get(), collection->getDefaultCollator()); - if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && - request->getProj().isEmpty() && hasCollectionDefaultCollation) { - LOGV2_DEBUG(20928, - 2, - "Using idhack: {unparsedQuery}", - "unparsedQuery"_attr = redact(unparsedQuery)); - - auto idHackStage = std::make_unique<IDHackStage>( - expCtx.get(), unparsedQuery["_id"].wrap(), ws.get(), descriptor); - unique_ptr<DeleteStage> root = - std::make_unique<DeleteStage>(expCtx.get(), - std::move(deleteStageParams), - ws.get(), - collection, - idHackStage.release()); - return PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, policy); + if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && + request->getProj().isEmpty() && hasCollectionDefaultCollation) { + LOGV2_DEBUG(20928, + 2, + "Using idhack: {unparsedQuery}", + "unparsedQuery"_attr = redact(unparsedQuery)); + + auto idHackStage = std::make_unique<IDHackStage>( + expCtx.get(), unparsedQuery["_id"].wrap(), ws.get(), descriptor); + unique_ptr<DeleteStage> root = + std::make_unique<DeleteStage>(expCtx.get(), + std::move(deleteStageParams), + ws.get(), + collection, + idHackStage.release()); + return PlanExecutor::make( + opCtx, std::move(ws), std::move(root), collection, policy); + } } // If we're here then we don't have a parsed query, but we're also not eligible for |