October 2017
Intermediate to advanced
226 pages
6h 56m
English
Compound indexes, if used smartly, can dramatically reduce your document seek times. For example, let's assume our application had a view that only required us to show a list of names in a city. A traditional approach would be to run a find query and get the list of documents and send them to the application's view. However, we know that other fields in the document are not needed for this view. Then, by having a compound index on city and first_name with the addition of field projection, we simply send the index values down to the application that is:
db.mockdata.find({city:'Boston', first_name:'Sara'}, {city:1, first_name:1, _id:0})
By doing this, not only do we leverage the speed of the index but we negate the need to fetch ...
Read now
Unlock full access