Mongo code 96
Mongodb: Sort operation used more than the maximum 33554432 bytes of RAM
1 mongo query data for paging, in some cases or some requirements use skip and limit to filter data, you can avoid the above errors. However, there is no problem with this method in the case of small data capacity, but the amount of data is large, and the above method may not work either.
The sort of mongo operates in memory. A mechanism of mongo limits the maximum memory for sorting to 32 megabytes. If the memory exceeds, an error will be reported.
Db.collection.find () .sort ({'key':-1}) .limit (5)
Db.collection.distinct ('key')
2 it is a reasonable choice to avoid this error by using the creation of index
Db.collection.createIndex ({"key":-1})-where-1 represents reverse order and 1 represents positive order