-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
200
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Due to the issue explained in SERVER-23229 the covered index plan can return null for missing fields in unoptimized plan. E.g.
- Optimized (covered index scan) plan output:
{a: 2, b: null}
- Unoptimized plan output:
{a: 2}
Script to reproduce
Enterprise test> db.coll.drop() true Enterprise test> const docs = [{a: 1, b: null}, {a: 2}, {a: 3, b: "string"}] Enterprise test> db.coll.insertMany(docs) { acknowledged: true, insertedIds: { '0': ObjectId('6a7de3ae5242dedc1cf36bc8'), '1': ObjectId('6a7de3ae5242dedc1cf36bc9'), '2': ObjectId('6a7de3ae5242dedc1cf36bca') } } Enterprise test> db.coll.find({a: 2}, {_id: 0, a: 1, b: 1}) [ { a: 2 } ] Enterprise test> db.coll.createIndex({a: 1, b: 1}) a_1_b_1 Enterprise test> db.coll.find({a: 1}, {_id: 0, a: 1, b: 1}) [ { a: 2, b: null } ]
- is related to
-
SERVER-23229 Projection incorrectly returns null value instead of missing field to user if projection is covered
-
- Backlog
-