受欢迎的博客标签

mongodb error message:Unable to execute query: errmsg: \"sort stage buffered data usage of 33565546 bytes exceeds internal limit of 33554432 bytes\"", "code" : 17007

Published
Reason:You're running into the 32MB limit on an in-memory sort: https://docs.mongodb.com/manual/reference/limits/#Sort-Operations   How to slove it? 1.solve it with indexing Better to declare an index so you don't need to sort in RAM Add an index to the sort field. That allows MongoDB to stream documents to you in sorted order, rather than attempting to load them all into memory on the server and sort them in memory before sending them to the client. db_handle.ensure_index([("reviewDate", pymongo.ASCENDING)])   2.slove it by increase buffer limit  you can increase buffer limit with your own defined optimal value, example 50 MB as below You can view the current buffer usage using the below command over the admin database: > use admin switched to db admin > db.runCommand( { getParameter : 1, "internalQueryExecMaxBlockingSortBytes" : 1 } ) { "internalQueryExecMaxBlockingSortBytes" : 33554432, "ok" : 1 } It has a default value of 32 MB(33554432 bytes).In this case you're running short of buffer data so you can increase buffer limit with your own defined optimal value, example 50 MB as below: > db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes:50151432}) { "was" : 33554432, "ok" : 1 }   Note:This commands supports only after version 3.0 + 3.slove it by use aggregation command use aggregation with disk usage If you want to avoid creating an index (e.g. you just want a quick-and-dirty check to explore the data), you can use aggregation with disk usage: all_reviews = db_handle.aggregate([{$sort: {'reviewDate': 1}}], {allowDiskUse: true}).