-
Type: Bug
-
Resolution: Duplicate
-
Priority: Trivial - P5
-
None
-
Affects Version/s: 2.4.5
-
Component/s: None
-
None
-
ALL
The indexOnly in an explain() is set to true even if the query needs fields which aren't in the index.
This is the example collection:
db.test.insert([{a:1,c:1},{a:2,c:1}]) db.test.ensureIndex({c:1}) db.test.find({a:1,c:1},{_id:0,c:1}).explain()
This is what the explain looks like:
> db.test.find({a:1,c:1},{_id:0,c:1}).explain() { "cursor" : "BtreeCursor c_1", "isMultiKey" : false, "n" : 1, "nscannedObjects" : 2, "nscanned" : 2, "nscannedObjectsAllPlans" : 4, "nscannedAllPlans" : 4, "scanAndOrder" : false, "indexOnly" : true, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "c" : [ [ 1, 1 ] ] }, "server" : "server:27017" }
indexOnly is set to true but MongoDB has to query on field a which is not part of the index c_1 - so it has to be false.
- duplicates
-
SERVER-5759 indexOnly in explain() is not reported correctly
- Closed