参考 > 参考 > mongo Shell方法 > 游标方法 > cursor.explain()
cursor.
explain
(冗长)¶mongo
壳法
此页面记录了mongo
shell方法,并且
没有引用MongoDB Node.js驱动程序(或任何其他驱动程序)方法。对于相应的MongoDB驱动程序API,请改为参考您特定的
MongoDB驱动程序文档。
提供有关该db.collection.find()
方法的查询计划的信息
。
该explain()
方法具有以下形式:
该explain()
方法具有以下参数:
参数 | 类型 | 描述 |
---|---|---|
verbose |
串 | 可选的。指定说明输出的详细模式。该模式影响行为 默认模式是 与早期版本的向后兼容性
有关这些模式的更多信息,请参见 详细模式。 |
该explain()
方法返回包含查询计划以及执行统计信息的文档。
的行为cursor.explain()
和返回的信息量取决于verbosity
模式。
queryPlanner
模式¶默认情况下,cursor.explain()
以queryPlanner
详细模式运行。
MongoDB运行查询优化器来为评估中的操作选择胜出计划。cursor.explain()
返回queryPlanner
评估方法的信息。
executionStats
模式¶MongoDB运行查询优化器以选择获胜计划,执行获胜计划直至完成,并返回描述获胜计划执行情况的统计信息。
cursor.explain()
返回所评估方法的queryPlanner
和
executionStats
信息。但是,executionStats
不提供被拒绝计划的查询执行信息。
allPlansExecution
模式¶MongoDB运行查询优化器以选择中奖计划并执行中奖计划以完成。在"allPlansExecution"
模式下,MongoDB返回描述获胜计划执行情况的统计信息以及在计划选择期间捕获的其他候选计划的统计信息。
cursor.explain()
返回所评估方法的queryPlanner
和
executionStats
信息。其中executionStats
包括中奖计划的
完整查询执行信息。
如果查询优化器考虑了多个计划,则
executionStats
信息还包括
在计划选择阶段为获胜和被拒绝的候选计划捕获的部分执行信息。
db.collection.explain().find()
¶db.collection.explain().find()
db.collection.find().explain()
与以下主要区别相似
:
db.collection.explain().find()
构造允许查询修饰符的其他链接。有关查询修饰符的列表,请参见db.collection.explain()。find()。help()。db.collection.explain().find()
返回游标,这需要一个电话.next()
,或它的别名.finish()
,返回explain()
结果。请参阅db.collection.explain()
以获取更多信息。
以下示例cursor.explain()
以“ executionStats”详细模式运行,
以返回指定db.collection.find()
操作的查询计划和执行信息:
cursor.explain()
操作可以返回有关以下内容的信息:
冗长模式(即queryPlanner
,executionStats
,
allPlansExecution
)确定结果是否包括
executionStats和是否executionStats包括期间捕获的数据计划选择。
有关输出的详细信息,请参见解释结果。