[SERVER-6293] Index only query fills in missing values with null Created: 03/Jul/12  Updated: 06/Dec/22  Resolved: 24/Jun/19

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

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 1
Labels: query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File server6293.js     File server6293.js     File server6293.js    
Issue Links:
Duplicate
duplicates SERVER-23229 Projection incorrectly returns null v... Backlog
Related
related to SERVER-4529 fast count mode should not be used wh... Closed
related to SERVER-12869 Index null values and missing values ... Backlog
is related to SERVER-23229 Projection incorrectly returns null v... Backlog
is related to SERVER-5580 covered indexes are improperly applie... Closed
is related to SERVER-11833 Projected field order different under... Closed
is related to SERVER-12056 hint() is not respected in find() Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

> db.bar.drop()
false
> db.bar.insert({_id:1})
> db.bar.insert({_id:2})
> db.bar.find({x:null}, {_id:1, x:1})
{ "_id" : 1 }
{ "_id" : 2 }
> db.bar.ensureIndex({x:1, _id:1})
> db.bar.find({x:null}, {_id:1, x:1})
{ "x" : null, "_id" : 1 }
{ "x" : null, "_id" : 2 }



 Comments   
Comment by Asya Kamsky [ 27/Dec/16 ]

Trivial way to reproduce the same behavior in current version without hint:

db.bar.drop()
db.bar.insert({_id:1})
db.bar.insert({_id:2})
db.bar.find({x:null}, {_id:1, x:1})
db.bar.ensureIndex({x:1, _id:1})
db.bar.find({x:{$ne:5}}, {_id:1, x:1})

Comment by Benety Goh [ 16/Dec/13 ]

added test script which uses hint to force use of index. This test script passes - no nulls are inserted into the results.

redbeard0531, can you pull from master and see if this works for you?

Comment by Mathias Stearn [ 06/Dec/13 ]

This is only fixed because it isn't indexOnly any more:

> db.bar.find({x:null}, {_id:1, x:1}).explain()
{
        "cursor" : "BasicCursor",
        "n" : 2,
        "nscannedObjects" : 2,
        "nscanned" : 2,
        "nscannedObjectsAllPlans" : 4,
        "nscannedAllPlans" : 4,
        "scanAndOrder" : false,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "server" : "redbeard:27017"
}

Comment by Benety Goh [ 04/Dec/13 ]

redbeard0531, this is no longer happening in 2.5 (you can use the attached test script). Can we resolve this?

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