【发布时间】:2013-02-12 02:26:20
【问题描述】:
请看下面的例子。在我看来,查询应该被索引{a: 1} 覆盖,但是explain() 给了我一个indexOnly: false。我做错了什么?
> db.foo.save({a: 1, b: 2});
> db.foo.save({a: 2, b: 3});
> db.foo.ensureIndex({a: 1});
> db.foo.find({a: 1}).explain();
{
"cursor" : "BtreeCursor a_1",
"nscanned" : 6,
"nscannedObjects" : 6,
"n" : 6,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"a" : [
[
1,
1
]
]
}
}
【问题讨论】:
-
它使用
cursor是BtreeCursor所示的索引。显然有六个文档 - 是否有任何关于其他文档的东西导致了这种行为? -
我认为您对“indexOnly”的解释是错误的,请参阅docs.mongodb.org/manual/applications/indexes/…
标签: mongodb indexing mongodb-indexes