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

mongoS changes projections for queries for unsharded collections unnecessarily

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.6.4
    • Fix Version/s: None
    • Component/s: Querying, Sharding
    • Labels:
      None

      Description

      In a sharded cluster, but using an unsharded collection, mongoS, given the query:

      mongos.getDB("db").foo.find({a:1}, {a:1}).sort({b:1})
      Index:{a:1}
      

      Will rewrite to:

      .find({a:1}, {a:1, b:1}).sort({b:1})
      

      This can be observed by running the mongoD at logLevel:2 or greater.

      As this is targeting a single shard, the query can run as is, mongoD will return everything in correct sorted order.

      Two possible answers:

      1. This is the correct behavior, we will always rewrite (and accept the cost of adding projections). Better for query plan cache filters.
      2. This isn't correct behavior and when a single shard is targeted the query shouldn't be rewritten. Better for speed and efficiency.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: