Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7408

Need to handle $limit differently in sharding if before first $sort or $group

    • Fully Compatible
    • ALL

      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.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: