Development Program error Message:
caused By:com.mongodb.MongoException:Executor error:
Operationfailed:sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.
From the program error, you can see that the sort of memory is low.
Workaround: Version 3.x
Use admin
Db.admincommand ({getparameter: "*"}) #查看参数的配置
Db.admincommand ({setparameter:1, internalqueryexecmaxblockingsortbytes:335544320}) #修改内存为排序为320M
Other solutions: (by creating an index)
Db. Your Collection.createindex ({"Your field":-1}), here-1 for reverse, 1 for positive sequence;
Db. Your collecton.getindexes ();
Refer to the official documentation:
https://docs.mongodb.com/manual/reference/method/cursor.sort/#cursor. Sort
https://docs.mongodb.com/manual/tutorial/optimize-query-performance-with-indexes-and-projections/
Recommended solutions for these issues:
1. Optimize queries and indexes.
2. Reduce the output column (limit the number of output columns) or rows (such as the limit function, or limit the number of input query _id).
3. The query is divided into 2 steps, the 1th step only output _id, the 2nd step through _id to find thin.
Can solve the in-memory sort overflow problem.
A case of MongoDB error