[SERVER-6253] Covered index not working on sub documents Created: 29/Jun/12  Updated: 15/Aug/12  Resolved: 29/Jun/12

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

Type: Improvement Priority: Major - P3
Reporter: René de Kat 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-2104 covered index should support dotted f... Closed
Participants:

 Description   

I have a problem with indexes on subdocuments where indexOnly is always false.

Take this code for example from the Mongo Docs (altered a bit to resemble my problem):

db.factories.insert( { name: "xyz", metro:

{ city: "New York", state: "NY" }

} );
db.factories.ensureIndex(

{"metro.city":1}

);
db.factories.find(

{ "metro.city" : "New York" }

, {_id:0, "metro.city" : 1} ).explain();
Output:
{
"cursor" : "BtreeCursor metro.city_1",
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" :

{ "metro.city" : [ [ "New York", "New York" ] ] }

}

Notice the indexOnly is false although an index is used and only indexed values should be returned. Hence the {_id:0, "metro.city" : 1} part.
Is this because the more than just the metro.city is returned? { "metro" :

{ "city" : "New York" }

}
Anybody any idea how I can make sure indexOnly becomes true in this situation?



 Comments   
Comment by Scott Hernandez (Inactive) [ 29/Jun/12 ]

Dup of SERVER-2104

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