MongoDB explain()光标字段
我开始调查MongoDB,并通过索引查看查询统计和优化。我正在阅读的示例使用解释函数,但它们的输出与我的不同 他们看起来像:MongoDB explain()光标字段,mongodb,Mongodb,我开始调查MongoDB,并通过索引查看查询统计和优化。我正在阅读的示例使用解释函数,但它们的输出与我的不同 他们看起来像: { "cursor" : "BtreeCursor username_1", "nscanned" : 1, "nscannedObjects" : 1, "n" : 1, "millis" : 3, "nYields" : 0, "nChunkSkips" : 0, "isMultiKey" : false
{
"cursor" : "BtreeCursor username_1",
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 3,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"username" : [
[
"user101",
"user101"
]
]
}
}
而我的:
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "yodemo2-dev.indexTest",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : [ ]
},
"winningPlan" : {
"stage" : "COLLSCAN",
"filter" : {
"$and" : [ ]
},
"direction" : "forward"
},
"rejectedPlans" : [ ]
},
"serverInfo" : {
"host" : "Andromache.local",
"port" : 27017,
"version" : "3.0.3",
"gitVersion" : "nogitversion"
},
"ok" : 1
}
我也使用了详细的版本,尽管示例中不是这样,但没有任何效果
如何获得结果?explain()输出在3.0中发生了更改。“他们的”是您使用的MongoDB的哪个版本?您还可以将您所做的所有查询(包括提供给
explain()
)的参数)添加到帖子中吗?我正在运行3.0.3版。我的查询是“db.indexTest.find().explain()”。indexTest是一个集合,包含数千个非常简单的文档,通过简单的for循环生成,循环的索引被连接到它们的name参数。那么,当您运行explain with verbose选项,如explain(“allPlansExecution”)
以及explain(“executionStats”)
时,输出是什么呢?太好了。但是,我如何才能获得这些信息?我似乎需要“游标”键。如果你调用explain(true)(又称verbose),你将从