|
The executionStats for count() shows that totalDocsExamined is not 0 when a covered query contains an $in with multiple values in the array, but the equivalent find() has 0 totalDocsExamined.
db.keys_examined.explain('executionStats').find({x: "A", y: {$in: [1, 2]}}, {_id: 0, y: 1})
|
Returns the expected executionStats
"nReturned" : NumberInt(2),
"totalKeysExamined" : NumberInt(3),
"totalDocsExamined" : NumberInt(0)
db.keys_examined.explain('executionStats').count({x: "A", y: {$in: [1]}})
|
Returns the expected executionStats
"nReturned" : NumberInt(0),
"totalKeysExamined" : NumberInt(2),
"totalDocsExamined" : NumberInt(0)
db.keys_examined.explain('executionStats').count({x: "A", y: {$in: [1, 2]}})
|
I would expect that totalDocsExamined would still be 0, but executionStats returns
"nReturned" : NumberInt(0),
"totalKeysExamined" : NumberInt(3),
"totalDocsExamined" : NumberInt(2)
|