[SERVER-7408] Need to handle $limit differently in sharding if before first $sort or $group Created: 18/Oct/12  Updated: 11/Jul/16  Resolved: 05/Nov/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.2.2, 2.3.1

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

On a single system the following aggregation can't return a count > 10:

db.foo.aggregate({$limit:10}, {$group: {_id:1, count: {$sum:1}}})

On a sharded system, this can return a count of 10 * numShards.

We probably want the limit applied both on the shard (for speedup) and on the mongos (for correctness).

Luckily, this isn't likely to affect many users since $limit usually follows a $sort or a $group which both force everything after to run in mongos.



 Comments   
Comment by auto [ 06/Nov/12 ]

Author:

{u'date': u'2012-10-18T21:21:45Z', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: SERVER-7408 Correctly handle $skip and $limit in sharded agg

This bug only comes up if the first $skip or $limit precedes the first
$sort or $limit. This is very rare, but should still be handled
correctly.
Branch: v2.2
https://github.com/mongodb/mongo/commit/f4270abac0d8ca752216e11256f93eb176c6ed8c

Comment by auto [ 05/Nov/12 ]

Author:

{u'date': u'2012-10-18T21:21:45Z', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: SERVER-7408 Correctly handle $skip and $limit in sharded agg

This bug only comes up if the first $skip or $limit precedes the first
$sort or $limit. This is very rare, but should still be handled
correctly.
Branch: master
https://github.com/mongodb/mongo/commit/d8384a53036b471099b8d293ac21b7bd4809df33

Generated at Thu Feb 08 03:14:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.