[SERVER-4666] sparse indexes break $exists query Created: 12/Jan/12  Updated: 29/Feb/12  Resolved: 12/Jan/12

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: 2.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Colin Howe 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-3918 make sparse indexes error out on {$ex... Closed
Operating System: ALL
Participants:

 Description   

Adding a sparse index breaks $exists queries on that field.

Sample console session:

use bug
// switched to db bug
db.bug.insert({a: 1})
db.bug.ensureIndex({b: 1}, {sparse: true})
db.bug.find({b: {$exists: false}})
// no result!
db.bug.find({b: {$exists: false}}).hint({$natural: 1})
// { "_id" : ObjectId("4f0c337f3715b68266d07790"), "a" : 1 }



 Comments   
Comment by Aaron Staple [ 12/Jan/12 ]

Hi Colin - I think we already have a ticket for this issue. Please feel free to comment on SERVER-3918.

Comment by Colin Howe [ 12/Jan/12 ]

I guess the problem here is that the optimizer chooses to use the index - incorrectly.

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