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

Mongos should re-write $in queries on the shard key before sending them to the shards so that the shards only receive the relevant portion of the $in

    • Query

      In a sharded environment, a query like

      {_id : {$in : [100, 200, 300, 400, 500, 600...]}}
      

      should be re-written by mongos by first resolving each _id value to the containing shard then sending the corresponding sub-qery to the right shard (assuming that _id is the shard key).

      For example, if 100, 300, 500 belong to shard1 and 200, 400, 600 belong to shard2 MongoS should make exactly 2 queries:

      {_id : {$in : [100, 300, 500]}}
      

      to shard1
      and

      {_id : {$in : [200, 400, 600]}}
      

      to shard2.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            spencer@mongodb.com Spencer Brody (Inactive)
            Votes:
            10 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: