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

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 Stearn
              Reporter:
              Mathias Stearn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: