如何获得有关MongoDB计数的解释? [英] How to get an explain for a MongoDB count?
本文介绍了如何获得有关MongoDB计数的解释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MongoDB中,您可以获得有关如何执行查询的说明,其中包含有趣的性能信息:
In MongoDB, you can get an explanation for how a query was executed, with interesting performance information:
> db.people.find({ 'items' : { '$gte' : 1 } }).explain()
我可以为计数"(不是查询,而是命令)获得相同的信息吗?
Can I get the same for a "count" (which is not a query, but a command)?
> db.people.count({ 'items' : { '$gte' : 1 } })
推荐答案
Mongo 3.0引入了一种解释非光标请求的新方法:
Mongo 3.0 introduced a new way of explaining non-cursor requests:
db.my_collection.explain().count()
请参阅: http://docs.mongodb.org/手册/参考/方法/db.collection.explain/#db.collection.explain
这篇关于如何获得有关MongoDB计数的解释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文