Consider this object:
{
"_id" : ObjectId("5a3040438c901f42d061edff"),
"TrackingId" : {
"FullValue" : "myRandomValue",
"PrintValue" : "myRandomValue2",
"BarcodeValue" : "myRandomValue3"
}
}
What is the difference between doing the following:
db.myColl.createIndex( { TrackingId: 1 }} )
vs
db.myColl.createIndex( { TrackingId.FullValue : 1 } )
As you can see in the first scenario I am indexing the entire object, since it is small I have no issues doing this. However I could also index the attribute within that object. My question then is, which one of these indexes would make a look up by TrackingId.FullValue more efficient and why?