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/