mongodb db.collection.find({}) 在 .limit(101) 之后什么都不做 [英] mongodb db.collection.find({}) does nothing past .limit(101)

查看:61
本文介绍了mongodb db.collection.find({}) 在 .limit(101) 之后什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

node-mongodb 版本 2.0.43 &MongoDB shell 版本:3.2.5

centos 虚拟机

我有一个(无上限的)1600 个文档(不是很大)的集合,并且所有文档都有标准的 BSON _id

如果我这样做

db.collection('docs').find({}).limit(100).toArray(function(e,r){console.log('done');});

我等待大约 1/2 秒的结果!

但是,如果我这样做了

db.collection('docs').find({}).toArray(function(e,r){console.log('done');})

我在这里坐了 5-10 分钟就放弃了.

<小时>

然后我将限制设置为 200(期望结果需要 x2,只要限制为 100,但它永远不会出现)

接下来我缩小了尝试限制 150,101,110,105,103,102

并发现结果在 101 限制后停止!

这似乎完全没有用处,就像我遇到了真正的问题.

如果 limit(200) 花了两倍的时间,那么我会说这是我查询中的性能问题,但它只是挂起,101 个结果令人不满意!!一个糟糕的假设:更不用说我的即时担忧,即如果任何查询有超过 100 个要查看的项目,我的应用可能会在任何时候挂起)

每个文档看起来都是这样

<代码>{"_id": "578eaa1ae642785679cd98b0","linkid": "12633170","advertiserid": "4612127","websitename": "租车 8","destinationurl": "https://www.carrental8.com/en/","谁": "8027061-12633170-1467924618000","href": "http://www.tkqlhce.com","src": "http://www.awltovhc.com",r1":3,r2":44,r3":24,r4":58}

另一个假设:我不认为

将这两行添加到/etc/security/limits.conf

root soft nofile 10000根硬盘文件 10000

还尝试了 https://serverfault.com/questions/591812/how-to-set-ulimits-for-mongod

重启服务器并启动mongod但没有变化!

解决方案

由 Mongodb 工作人员 (Christian Amor Kvalheim) 修复,成员建议升级

npm install mongodb@2.2.4

node-mongodb version 2.0.43 & MongoDB shell version: 3.2.5

centos vm

I have an (un-capped) collection of 1600 documents (not very big) and all of them have standard BSON _ids

if I do

db.collection('docs').find({}).limit(100).toArray(function(e,r){console.log('done');});

I wait about 1/2 a second for the result!

But, then if I do

db.collection('docs').find({}).toArray(function(e,r){console.log('done');})

I'm sitting here for 5-10 minutes and give up.


So then I set the limit to 200 (expecting the result to take x2 as long as limit 100, but it never comes)

Next I narrowed it down trying limits 150,101,110,105,103,102

and found that results stop after the 101 limit!

That seems totally void of usefulness and like there is a real problem to me.

If limit(200) took twice as long then I would say it's a performance issue in my query but it just hangs and 101 results is way way way unsatisfying!! A poor assumption: Not to mention my instant concern that at any point in time my app could hang If any query has above 100 items to look through)

each doc looks like so

{
"_id": "578eaa1ae642785679cd98b0",
"linkid": "12633170",
"advertisercid": "4612127",
"websitename": "Car Rental 8",
"destinationurl": "https://www.carrental8.com/en/",
"who": "8027061-12633170-1467924618000",
"href": "http://www.tkqlhce.com",
"src": "http://www.awltovhc.com",
"r1": 3,
"r2": 44,
"r3": 24,
"r4": 58
}

Another assumption: I don't think profiling will work on a query that does not finish?

Also what strikes me as very odd is that the query speed isn't really declining much up to 101 then BOOM nothing..

Why does the query hang forever and not just get slower?

mongodb.log shows nothing wrong

Tried db.command({ profile : 1, slowms : 10 }); right before find but no profile seems to happen.


yum update mongodb-org made no change although It did update: mongodb-org-server, mongodb-org-mongos, mongodb-org-shell and mongodb-org-tools!

Replicated the exact same collection onto a dedicated server

It works there by not on the vm

the took a screen shot of the vm's memory before (blue) and after hanging (red) but I don't see a sizable change

added these two lines to /etc/security/limits.conf

root             soft    nofile          10000
root             hard    nofile          10000

also tried https://serverfault.com/questions/591812/how-to-set-ulimits-for-mongod

restarted server and started mongod but no change!

解决方案

Fixed by a Mongodb staff (Christian Amor Kvalheim) members advice to upgrade

npm install mongodb@2.2.4

这篇关于mongodb db.collection.find({}) 在 .limit(101) 之后什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆