MongoDB Sort operation used more than the maximum 33554432 bytes of RAM

Source: Internet
Author: User
Tags mongodb

MONGO in the use of the process encountered a problem, the need is to MONGO library query to the data paging, MONGO library we know that will store large volumes of data, if there is more data in the library, this will be reported a query failed with error code, and ER ROR message ' Executor error during find Command:OperationFailed:Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit. '

According to the error, know that this is a sort of the wrong time, because the MONGO sort operation is in memory operation, will inevitably occupy memory, while the MONGO within a mechanism to limit the maximum memory of 32M, when the amount of data sorted more than 32M, will be reported above this error, The solution is like the above hint, one is to increase the MONGO of the sort of memory, this is generally operations to the tube, there are drawbacks, that is, the amount of data if again large, but also to add. Another way is to add index, this method is very convenient. Creating an index takes effect in a timely manner without restarting the service. It's not hard to create an index,

Db. Your Collection.createindex ({"Your field":-1}), here-1 for reverse, 1 for positive sequence;

Db. Your collecton.getindexes ();

These two statements, the first is to add an index, the second is the query index, if you look at the index field you just added, the index was added successfully. This time in your program to use the sort method, so that will not error and fast.

Adding an index can have some drawbacks, which can lead to slower data insertions than before because the index occupies space. In the light of the actual situation, the appropriate method should be used.

MongoDB Sort operation used more than the maximum 33554432 bytes of RAM

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.