A case of MongoDB error

Source: Internet
Author: User
Tags mongodb

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.