summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2022-11-11 20:04:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-11 20:55:05 +0000
commitbaafd67539f65f9ab620f4d67431881013fa66b5 (patch)
treeef699833220ab64a1dd923e22321bca476390cdf /src/mongo/db/commands
parentdf38314f471a57fd273a7c0d747dfc1aeb4feaea (diff)
downloadmongo-baafd67539f65f9ab620f4d67431881013fa66b5.tar.gz
SERVER-69801 Support sampling aggregate queries on sharded clusters
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index 5f923f7aa10..1e46d2a8894 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -945,15 +945,6 @@ Status runAggregate(OperationContext* opCtx,
}
}
- if (analyze_shard_key::supportsPersistingSampledQueries() && request.getSampleId()) {
- analyze_shard_key::QueryAnalysisWriter::get(opCtx)
- .addAggregateQuery(*request.getSampleId(),
- expCtx->ns,
- pipeline->getInitialQuery(),
- expCtx->getCollatorBSON())
- .getAsync([](auto) {});
- }
-
// If the aggregate command supports encrypted collections, do rewrites of the pipeline to
// support querying against encrypted fields.
if (shouldDoFLERewrite(request)) {
@@ -968,6 +959,15 @@ Status runAggregate(OperationContext* opCtx,
constexpr bool alreadyOptimized = true;
pipeline->validateCommon(alreadyOptimized);
+ if (analyze_shard_key::supportsPersistingSampledQueries() && request.getSampleId()) {
+ analyze_shard_key::QueryAnalysisWriter::get(opCtx)
+ .addAggregateQuery(*request.getSampleId(),
+ expCtx->ns,
+ pipeline->getInitialQuery(),
+ expCtx->getCollatorBSON())
+ .getAsync([](auto) {});
+ }
+
if (isEligibleForBonsai(request, *pipeline, opCtx, collections.getMainCollection())) {
uassert(6624344,
"Exchanging is not supported in the Cascades optimizer",