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

sort by shard key or prefix of shard key may not require merge before group

    • Query Optimization

      Consider the following scenario:

      Collection is sharded on field "symbol":

      db.coll.aggregate({$sort:{symbol:1, date:1}},{$group:{_id:"$symbol", first:{$first:"$start"},last:{$last:"$start"}, sum:{$sum:"$volume"}}})
      

      This pipeline will merge because of sort even though it does not need to.

      Related but not quite the same is SERVER-5477 which would allow the group to take place on the single shard in this example, but it wouldn't happen if $sort by shard key also wasn't correctly handled.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: