Glu*_*luz 11 mongodb mongohq mongodb-ruby
我的查询需要很长时间才能完成.我喜欢做一些性能测试但是在我检查一次(当前需要约30秒)之后,查询开始运行得更快(<1秒).我认为它必须与mongodb缓存.有没有办法禁用mongodb的缓存或其他方式我可以检查性能?
我在mongohq使用mongodb.使用Ruby on Rails编程3.以下是解释:
{"cursor"=>"BtreeCursor start_-1", "nscanned"=>5276, "nscannedObjects"=>5276, "n"=>25, "millis"=>3264, "nYields"=>0, "nChunkSkips"=>0, "isMultiKey"=>false, "indexOnly"=>false, "indexBounds"=>{"start"=>[[{"$maxElement"=>1}, {"$minElement"=>1}]]}, "allPlans"=>[{"cursor"=>"BtreeCursor attendees_count_-1", "indexBounds"=>{"attendees_count"=>[[1.7976931348623157e+308, 1]]}}, {"cursor"=>"BtreeCursor images_count_-1", "indexBounds"=>{"images_count"=>[[1.7976931348623157e+308, 2]]}}, {"cursor"=>"BtreeCursor start_-1", "indexBounds"=>{"start"=>[[{"$maxElement"=>1}, {"$minElement"=>1}]]}}, {"cursor"=>"BtreeCursor start_-1_end_-1", "indexBounds"=>{"start"=>[[{"$maxElement"=>1}, {"$minElement"=>1}]], "end"=>[[{"$maxElement"=>1}, {"$minElement"=>1}]]}}, {"cursor"=>"BtreeCursor attendees._id_1 multi", "indexBounds"=>{"attendees._id"=>[[BSON::ObjectId('4f0b621e94bb688563000007'),BSON::ObjectId('4f0b621e94bb688563000007')], [BSON::ObjectId('4f0b647d5a8c00acde05236f'), BSON::ObjectId('4f0b647d5a8c00acde05236f')], [BSON::ObjectId('4f0b647d5a8c00acde052370'), BSON::ObjectId('4f0b647d5a8c00acde052370')], [BSON::ObjectId('4f0b647d5a8c00acde052371'), BSON::ObjectId('4f0b647d5a8c00acde052371')], [BSON::ObjectId('4f0b647d5a8c00acde052372'), BSON::ObjectId('4f0b647d5a8c00acde052372')], [BSON::ObjectId('4f0b647d5a8c00acde052373') ... (lots of Object IDs)]]}}}
Run Code Online (Sandbox Code Playgroud)
请注意,我不得不截断一些解释,因为它太长了.存在"大量对象ID"的地方有很多对象ID(~400).
谢谢大家
我想您无法阻止 Mongo 准备查询计划(这就是 mongo 的工作方式)。因此,在查询统计信息之前.. 1. 通过以下方式清除所有集合的计划缓存
>db.colllction_name.getPlanCache().clear()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5657 次 |
| 最近记录: |