mongodb查询统计explain介绍

explain在3.2版本之前的使用

db.name.find().explain()

explain在3.2版本以后的使用

最新的explain()方法制定了一个新的输出解释模式,分别是”queryPlanner”, “executionStats”, 和”allPlansExecution”.

分别指的是:概要模式,执行状态模式,所有信息模式,默认的是概要模式。而我们所需要查看的参数通常是包含在“执行状态模式”中

db.pages.explain("executionStats").find()
#explain()函数可以放到find()前和后都行
db.pages.find().explain("executionStats")

explain()的API:https://docs.mongodb.com/manual/reference/method/db.collection.explain/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容