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

Multikey index does not provide nonblocking sort in MongoDB 3.6

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.2
    • Component/s: Querying
    • Labels:
      None
    • ALL
    • Hide

      1. Create a collection with a huge number of records with the fields (dd, refKey, hashSum, _id)
      2. Create an index on (dd:1, refKey:1, hashSum:1, _id:1)
      3. Execute this query:

       db.customer.find({"dd": "com.x"}).sort({"dd":1, "refKey":1, "hashSum":1, "_id":1})
      Show
      1. Create a collection with a huge number of records with the fields (dd, refKey, hashSum, _id) 2. Create an index on (dd:1, refKey:1, hashSum:1, _id:1) 3. Execute this query: db.customer.find({"dd": "com.x"}).sort({"dd":1, "refKey":1, "hashSum":1, "_id":1})

      Original Summary

      MongoDB 3.6.2 not using the index for sort where the prefix key of the index appears in both the query predicate and the sort.

      Original Description

      MongoDB 3.6.2 not using the index for sort where the prefix key of the index appears in both the query predicate and the sort.
      We have a collection called customer with 316432 records and using mongoDB 3.6.2.

      Trying to execute the query:

      db.customer.find({"dd": "com.x"}).sort({"dd":1, "refKey":1, "hashSum":1, "_id":1})
      

      where we have an index defined as:

      {"dd":1, "refKey":1, "hashSum":1, "_id":1}
      

      MongoDB doesn't use the index and tries to do the sort in memory and hits the 32MB limit.

      Error: error: {
      	"ok" : 0,
      	"errmsg" : "errmsg: \"Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.\"",
      	"code" : 96,
      	"codeName" : "OperationFailed",
      	"operationTime" : Timestamp(1519024594, 1)
      }
      

      Request your help in this regard since it is very urgent and blocking.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            praveen.reachable@gmail.com PRAVEEN SUBBA RAO
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: