[SERVER-47374] Query with empty in clause performs collection scan Created: 06/Apr/20  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: 4.0.17
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Peter Williamson Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 1
Labels: qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File reproduce.txt    
Issue Links:
Related
is related to SERVER-3337 $all with an empty array should retur... Backlog
Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

db.collection.explain().aggregate([{$match: {Field: {$in: []}}}])

or

db.collection.find({Field: {$in: []}}).explain("executionStats")

Where there is no index on Field 

Participants:

 Description   

Both find and aggregate will perform a scan when the search criteria is {$in: [ ]} and the searched field is not indexed. 

IMHO the query should either immediately return zero documents or throw an error due to the empty array.


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