Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongo code 96

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report