Mongodb中的explain():"nscanned"和"nscanned"之间的区别和"nscannedObjects" [英] explain() in Mongodb: differences between "nscanned" and "nscannedObjects"

查看:310
本文介绍了Mongodb中的explain():"nscanned"和"nscanned"之间的区别和"nscannedObjects"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Mongodb的说明查询输出中获得"nscanned"和"nscannedObjects"之间的确切区别.

I cannot get the exact difference between "nscanned" and "nscannedObjects" in the Mongodb's explain query output.

关于 MongoDB解释文档我可以阅读:

nscanned (已扫描的项目数)(文档或索引条目).项目 可能是对象或索引键.如果涉及覆盖索引", nscanned可能高于nscannedObjects.

nscanned Number of items (documents or index entries) examined. Items might be objects or index keys. If a "covered index" is involved, nscanned may be higher than nscannedObjects.

nscannedObjects 扫描的文档数.

这两个字段之间有什么区别? 更具体地讲,当我使用BtreeCursor(索引)进行查询时,这究竟意味着什么,而这两个字段具有两个不同的值,例如:

What's the different between these two fields? And more specific what does exactly mean when I have a query, which uses a BtreeCursor (an index), and these two fields have two different values, for example:

{
    "cursor" : "BtreeCursor a_1_b_1",
    "isMultiKey" : false,
    "n" : 5,
    "nscannedObjects" : 5,
    "nscanned" : 9, 
    (...)
}

我知道什么是"已覆盖索引" . 我想确切地了解查询在上面的示例中做了什么. 它是否通过了9个元素(nscanned = 9)(其中"nscanned = 9"),它们全部都是索引条目,并且仅读取(检查")其中5个元素(nscannedObjects = 5)的值以生成结果集? /p>

I know what a "covered index" is. I would like to understand exactly what the query did in the example above. Did it pass through ("scanned") 9 elements (nscanned = 9), where all of them are index entries and read ("examined") the value of only 5 of them (nscannedObjects = 5) to produce the result set?

推荐答案

这意味着:
查询返回5个文档-n
从索引中扫描了9个文档-nscanned
然后从集合中读取5个完整文档-nscannedObjects

This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects

类似的示例在:
http://docs.mongodb.org/manual/reference/method/cursor.explain /#cursor.explain

Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain

这篇关于Mongodb中的explain():"nscanned"和"nscanned"之间的区别和"nscannedObjects"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆