diff options
author | Ian Boros <ian.boros@mongodb.com> | 2021-01-22 12:01:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-26 15:00:51 +0000 |
commit | 31b07a007b80975852f75b43ba3437782825bf23 (patch) | |
tree | 3947e78c741ddf879a4ab6f29b05490b34d6ec84 | |
parent | 528562109ae37edde02ebd5fc4c94edafc45caeb (diff) | |
download | mongo-31b07a007b80975852f75b43ba3437782825bf23.tar.gz |
SERVER-53975 Fix performance of group-by-count aggregations
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner.cpp | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index a1617aefff9..059217598a8 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -679,7 +679,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> PipelineD::prep invariant(hasNoRequirements); // Any data returned from the inner executor must be owned. - size_t plannerOpts = QueryPlannerParams::DEFAULT | QueryPlannerParams::RETURN_OWNED_DATA; + size_t plannerOpts = QueryPlannerParams::DEFAULT; if (pipeline->peekFront() && pipeline->peekFront()->constraints().isChangeStreamStage()) { invariant(expCtx->tailableMode == TailableModeEnum::kTailableAndAwaitData); @@ -736,6 +736,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> PipelineD::prep // projection at the front of the pipeline, it will be removed and handled by the PlanStage // layer. If a projection cannot be pushed down, an empty BSONObj will be returned. projObj = buildProjectionForPushdown(deps, pipeline); + plannerOpts |= QueryPlannerParams::RETURN_OWNED_DATA; } if (rewrittenGroupStage) { diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index 129e8eec83a..a910d7504d3 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -590,6 +590,13 @@ StatusWith<std::unique_ptr<QuerySolution>> QueryPlanner::planFromCache( // static StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan( const CanonicalQuery& query, const QueryPlannerParams& params) { + // It's a little silly to ask for a count and for owned data. This could indicate a bug earlier + // on. + tassert(5397500, + "Count and owned data requested", + !((params.options & QueryPlannerParams::IS_COUNT) && + (params.options & QueryPlannerParams::RETURN_OWNED_DATA))); + LOGV2_DEBUG(20967, 5, "Beginning planning", |