溢出排序阶段缓冲的数据使用量超过内部限制 [英] Overflow sort stage buffered data usage exceeds internal limit
问题描述
使用代码:
all_reviews = db_handle.find().sort('reviewDate', pymongo.ASCENDING)
print all_reviews.count()
print all_reviews[0]
print all_reviews[2000000]
计数打印2043484
,然后打印all_reviews[0]
.
但是在打印 all_reviews[2000000]
时,我收到错误:
However when printing all_reviews[2000000]
, I get the error:
pymongo.errors.OperationFailure: 数据库错误: Runner 错误: 溢出排序阶段缓冲的 33554495 字节数据使用超过了 33554432 字节的内部限制
pymongo.errors.OperationFailure: database error: Runner error: Overflow sort stage buffered data usage of 33554495 bytes exceeds internal limit of 33554432 bytes
我该如何处理?
推荐答案
您遇到了内存中排序的 32MB 限制:
You're running into the 32MB limit on an in-memory sort:
https://docs.mongodb.com/manual/reference/limits/#Sort-Operations
为排序字段添加索引.这允许 MongoDB 按排序顺序将文档流式传输给您,而不是尝试将它们全部加载到服务器上的内存中并在将它们发送到客户端之前在内存中对其进行排序.
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.
这篇关于溢出排序阶段缓冲的数据使用量超过内部限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!