summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp')
-rw-r--r--src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
index 430378b2a41..62dbd96b5ab 100644
--- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
@@ -59,6 +59,7 @@
#include "mongo/db/query/query_knobs_gen.h"
#include "mongo/db/query/sbe_plan_cache.h"
#include "mongo/db/repl/primary_only_service.h"
+#include "mongo/db/s/query_analysis_writer.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/s/transaction_coordinator_curop.h"
#include "mongo/db/s/transaction_coordinator_worker_curop_repository.h"
@@ -74,6 +75,7 @@
#include "mongo/logv2/log.h"
#include "mongo/s/cluster_commands_helpers.h"
#include "mongo/s/query/document_source_merge_cursors.h"
+#include "mongo/s/query_analysis_sampler_util.h"
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kQuery
@@ -423,6 +425,15 @@ CommonMongodProcessInterface::attachCursorSourceToPipelineForLocalRead(Pipeline*
return pipeline;
}
+ if (expCtx->eligibleForSampling()) {
+ if (auto sampleId = analyze_shard_key::tryGenerateSampleId(expCtx->opCtx, expCtx->ns)) {
+ analyze_shard_key::QueryAnalysisWriter::get(expCtx->opCtx)
+ .addAggregateQuery(
+ *sampleId, expCtx->ns, pipeline->getInitialQuery(), expCtx->getCollatorBSON())
+ .getAsync([](auto) {});
+ }
+ }
+
boost::optional<AutoGetCollectionForReadCommandMaybeLockFree> autoColl;
const NamespaceStringOrUUID nsOrUUID =
expCtx->uuid ? NamespaceStringOrUUID{expCtx->ns.dbName(), *expCtx->uuid} : expCtx->ns;