diff options
Diffstat (limited to 'src/mongo/db/commands/distinct.cpp')
-rw-r--r-- | src/mongo/db/commands/distinct.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 070da8d285c..eb599424001 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -57,6 +57,7 @@ #include "mongo/db/query/query_planner_common.h" #include "mongo/db/query/view_response_formatter.h" #include "mongo/db/s/collection_sharding_state.h" +#include "mongo/db/s/query_analysis_writer.h" #include "mongo/db/views/resolved_view.h" #include "mongo/logv2/log.h" #include "mongo/util/database_name_util.h" @@ -244,6 +245,16 @@ public: invocation->markMirrored(); } + if (analyze_shard_key::supportsPersistingSampledQueries() && parsedDistinct.getSampleId()) { + auto cq = parsedDistinct.getQuery(); + analyze_shard_key::QueryAnalysisWriter::get(opCtx) + .addDistinctQuery(*parsedDistinct.getSampleId(), + nss, + cq->getQueryObj(), + cq->getFindCommandRequest().getCollation()) + .getAsync([](auto) {}); + } + if (ctx->getView()) { // Relinquish locks. The aggregation command will re-acquire them. ctx.reset(); |