[SERVER-26831] count() examines docs on covered query with $in Created: 28/Oct/16  Updated: 29/Oct/16  Resolved: 29/Oct/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Brian Riley Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-17266 count command performance optimizatio... Backlog
Operating System: ALL
Steps To Reproduce:

db.keys_examined.createIndex({x: 1, y: 1})
db.keys_examined.insertMany([{'x': "A", 'y': 1}, {'x': "B", 'y': 1}, {'x': "A", 'y': 2}])
db.keys_examined.explain('executionStats').count({x: "A", y: {$in: [1, 2]}})

Participants:

 Description   

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)



 Comments   
Comment by Daniel Pasette (Inactive) [ 28/Oct/16 ]

Thanks for the report. Looks like a duplicate of SERVER-17266.

Generated at Thu Feb 08 04:13:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.