简体   繁体   English

如何在pyMongo中使用allowDiskUse选项?

[英]How to use allowDiskUse option in pyMongo?

I am getting following error when I am using 'Sort' operation in pyMongo : 当我在pyMongo中使用'Sort'操作时出现以下错误:

OperationFailure: Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. OperationFailure:查找命令期间执行器错误:OperationFailed:排序操作使用的RAM超过最大33554432字节。 Add an index, or specify a smaller limit. 添加索引,或指定一个较小的限制。 // Werkzeug Debugger // Werkzeug调试器

I can not limit the number of records. 我不能限制记录数。

Please suggest me a way around. 请给我建议一下。 TIA TIA

db.example.aggregate(
   [
     {$match : {key : matchvalue }},
     {$sort : {sortkey : -1/1}}
   ],
   {
       allowDiskUse: true // creates temp files if sort limit(100 MB) exceeds
   } 
);

This might be helpful. 这可能会有所帮助。 Its good to use the aggregate pipeline for this kind of tasks as MongoDB provides many operators. 将聚合管道用于此类任务非常好,因为MongoDB提供了许多运算符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM