[SERVER-9495] sort/limit optimization with {$in} expression isn't used if null is one of the values for $in. Created: 28/Apr/13  Updated: 06/Dec/22  Resolved: 06/Mar/16

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.4.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: indexing, query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

This looks like a partial regression of SERVER-5777

My test:
Index: {a:1, date:-1}
2.2.x query:

 
find({a:{$in:[1,2]}}).limit(5).sort({date:-1})  

correctly limits documents (nscanned and nscannedObject to 10).

find({a:{$in:[null,2]}}).limit(5).sort({date:-1})

same thing.

2.4.x query:

find({a:{$in:[1,2]}}).limit(5).sort({date:-1})

correctly limits to 10 docs.

find({a:{$in:[null,2]}}).limit(5).sort({date:-1})

scans all matching a documents without applying limit.



 Comments   
Comment by Asya Kamsky [ 06/Mar/16 ]

No longer an issue in any supported version.

Comment by Asya Kamsky [ 28/Apr/13 ]

Correction, I think technically it's a regression of SERVER-5063 for null value.

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