My request is below:
db.chats.find({ bid: 'someID' }).sort({start_time: 1}).limit(10).skip(82560).pretty()
I have indexes on a collection of chats in fields in that order
{ "cid" : 1, "bid" : 1, "start_time" : 1 }
I try to sort, but when I write a request and check the result of the explanation (), I still get a winning plan as
{ "stage":"SKIP", "skipAmount":82560, "inputStage":{ "stage":"SORT", "sortPattern":{ "start_time":1 }, "limitAmount":82570, "inputStage":{ "stage":"SORT_KEY_GENERATOR", "inputStage":{ "stage":"COLLSCAN", "filter":{ "ID":{ "$eq":"someID" } }, "direction":"forward" } } } }
I expected that I would not have a sorting stage, since I have indexes created for this collection. Missing indexes will result in the following error
MongoError: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM [duplicate]
However, I managed to do the sorting job by increasing the size distribution on the drum from 32 MB to 64 MB, looking for help in properly adding indexes
mongodb
Anoopgoudar
source share