Get the App
SLTechnology News&Howtos  ›  Database  › 

Mongo code 96

Shulou Source: shulou.com Published: 2022-06-01 07:30:34 09月22日 Update

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

Tags: Data representative memory situation error maximum nothing reverse order capacity large method is in mechanism this method index problem demand will report set sort Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Technology Linux MariaDB OPPO Reno