工具癖程序员

Robomongo执行循环语句超时

2017-10-09  本文已影响0人  一根弦的风筝

背景

在使用Robomongo进行查询时, 经常遇到执行结果不完整的问题, 即一个循环保存, 比如应该执行1000次, 结果只执行了200次, 而且没有任何错误报出, 这其实是因为Robomongo执行超时了, 默认为10秒

解决方案

  1. 找到配置文件

Windows
大于0.8
C:\Users<user>.config\robomongo\x.x.x\robomongo.json
0.8.x
C:\Users<user>.config\robomongo\robomongo.json
MAC
大于0.8
/Users/<user>/.config/robomongo/x.x.x/robomongo.json
0.8.x
/Users/<user>/.config/robomongo/robomongo.json
Linux
大于0.8
/home/<user>/.config/robomongo/x.x.x/robomongo.json
0.8.x
/home/<user>/.config/robomongo/robomongo.json

  1. 修改shellTimeoutSec值, 为60或更高, 单位为秒
  2. 保存后, 重新打开Robomongo

如果就是需要很长时间, 可以考虑使用批操作执行

var bulk = db.xxx.initializeUnorderedBulkOp();
db.xxx.find({}).forEach(function(obj){  
    bulk.find( { _id: obj._id } ).update({ $set: { xxx: obj.xxx} });
// or
    bulk.insert(obj);
});
bulk.execute();
上一篇下一篇

猜你喜欢

热点阅读