[SERVER-8551] Exists query with a sparse index should have nscannedObjects = 0 Created: 13/Feb/13  Updated: 15/Feb/13  Resolved: 13/Feb/13

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

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

2.4.0-rc0 on OS X


Issue Links:
Duplicate
duplicates SERVER-5759 indexOnly in explain() is not reporte... Closed
duplicates SERVER-3187 keymatch optimizations, in particular... Closed
Related
related to SERVER-8549 Not in covered index query does not h... Closed
Operating System: ALL
Steps To Reproduce:

testDB = db.getSiblingDB("qa293")
var coll = testDB.getCollection("simple.3")
coll.drop()
for (i=0;i<10;i++) {
coll.insert(

{foo:i}

)
}
for (i=0;i<5;i++) {
coll.insert(

{bar:i}

)
}
coll.insert(

{foo:"1"}

)
coll.insert({foo:{bar:1}})
coll.insert(

{foo:null}

)
coll.ensureIndex(

{foo:1}

,

{sparse:true, unique:true}

)

// Test exists query
var plan = coll.find({foo:{$exists:true}},

{foo:1, _id:0}

).hint(

{foo:1}

).explain()
assert.eq(true, plan.indexOnly, "simple.3.7 - indexOnly should be true on covered query")
assert.eq(0, plan.nscannedObjects, "simple.3.7 - nscannedObjects should be 0 for covered query")

Participants:

 Description   

An exists query on a sparse index field has indexOnly true but nscannedObjects > 0
The test case below asserts
assert: [0] != [13] are not equal : simple.3.7 - nscannedObjects should be 0 for covered query



 Comments   
Comment by Aaron Staple [ 13/Feb/13 ]

Hi Sridhar - Pretty much the same story here as with SERVER-8549.

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