-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.6.2
-
Component/s: Querying
-
None
-
ALL
-
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.
- related to
-
SERVER-19402 Change semantics of sorting by array fields in find and aggregate
- Closed
-
SERVER-31898 Improve sort analysis to allow multikey indexes to provide sorts when possible
- Closed