summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2019-10-10 22:16:39 +0000
committerevergreen <evergreen@mongodb.com>2019-10-10 22:16:39 +0000
commitd1a128b434d89f1cba3f1a4a60a117a55291b098 (patch)
tree0e961b0b4dc81e2762226b0a084595fbe8ca95f7 /src/mongo/s
parente408478d1f6283e279e57fedf63cd08ac2181d04 (diff)
downloadmongo-d1a128b434d89f1cba3f1a4a60a117a55291b098.tar.gz
SERVER-36723 Push $limit beneath DocumentSourceCursor into the PlanStage layer.
In addition towards working towards the general goal of doing as much query execution as possible with a PlanStage tree, this should have a positive performance impact for certain agg pipelines. Previously, a pipeline with a $project (or a $project-like stage such as $addFields) followed by a $limit might have applied this limit only after a full batch of data was loaded by DocumentSourceCursor. After this change, the limit will take effect prior to DocumentSourceCursor batching, and thus may reduce the amount of data processed by the query.
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/query/cluster_aggregation_planner.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/mongo/s/query/cluster_aggregation_planner.cpp b/src/mongo/s/query/cluster_aggregation_planner.cpp
index 1c03e375e00..19e24235923 100644
--- a/src/mongo/s/query/cluster_aggregation_planner.cpp
+++ b/src/mongo/s/query/cluster_aggregation_planner.cpp
@@ -128,15 +128,12 @@ boost::optional<long long> getPipelineLimit(Pipeline* pipeline) {
auto sortStage = dynamic_cast<DocumentSourceSort*>(source);
if (sortStage) {
- return (sortStage->getLimit() >= 0) ? boost::optional<long long>(sortStage->getLimit())
- : boost::none;
+ return sortStage->getLimit();
}
auto cursorStage = dynamic_cast<DocumentSourceSort*>(source);
if (cursorStage) {
- return (cursorStage->getLimit() >= 0)
- ? boost::optional<long long>(cursorStage->getLimit())
- : boost::none;
+ return cursorStage->getLimit();
}
// If this stage is one that can swap with a $limit stage, then we can look at the previous