14. Covered Indexes
• New in 1.7.4
• Query can be resolved in index only
• Need to exclude _id from items projected
db.user.ensureIndex({‚title‛: 1})
db.user.find({‚title‛: ‚My blog post:},
{title: 1, _id:0}))
15. Sparse Indexes
• Included if and only if indexed values is present
• Limited to single field
db.user.ensureIndex({ title : 1} , {sparse :true} )
db.user.save({ name : Rohan})
db.user.save({ name : Ram , title : princes })
Return only Ram
db.user.find ( { title : { $ne : null} } ) .sort({ title : 1} )
20. Strategies
• The application queries.
• The relative frequency of query in application.
• Current indexes for your application.
• Which indexes most common query use.
21. • Use indexes to sort query result
• Ensure that your indexes fit entirely in RAM
• Consider Performance when Creating Indexes for Write-
heavy Applications
22. Review
• Understand your workload
– Profile your queries
– Use explain on the slow ones
• Create indexes for slow operations