[SERVER-8549] Not in covered index query does not 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:

> db.version()
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
is related to SERVER-8551 Exists query with a sparse index shou... Closed
Operating System: ALL
Steps To Reproduce:

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

{foo:i}

)
}
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}

)

// Test not in query
var plan = coll.find({foo:{$nin:[5,8]}},

{foo:1, _id:0}

).hint(

{foo:1}

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

Participants:

 Description   

Expecting a covered index query to have nscannedObjects to be 0 with a nin query on the indexed field. This is the case when the index is a regular, unique or sparse unique.



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

Hi Sridhar - in this case nscannedObjects is being reported based on the current matching implementation which does not implement covered index matching for $nin predicates. The ticket for implementing that in this case is SERVER-3187. Also in this example indexOnly is being reported incorrectly. The ticket for fixing that is SERVER-5759.

Comment by Sridhar Nanjundeswaran [ 13/Feb/13 ]

Error on the assert is assert: [0] != [28] are not equal : simple.1.8 - nscannedObjects should be 0 for covered query

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