Conclusion / Learn
MongoDB Indexes II
In this unit, you learned how to:
- Identify which fields in the
explain()output will indicate a performance issue, i.e.nReturned,totalDocsExamined,totalKeysExamined - Set the verbosity level for
explain(), i.e.executionStats - Run
explain()on a query to determine if the query is using an index - Read the
explain()output run on a query and identify what index a query is using - Create an efficient compound index for a given query
- Create a wildcard index
- Create a partial index
- Create a sparse index
- Create a clustered time series index
- Use
$indexStatsto view the indexes with the most operations and unused indexes in a collection - Enable profiling and set the profiling level using
db.setProfilingLevel() - Use Database Profiler (
system.profilecollection) to identify slow queries
Resources
Use the following resources to learn more about Indexing with MongoDB:
Lesson 1: How Indexes Work
- Indexes in MongoDB
- What is Indexing in a Database?
- Compound Indexes
- MongoDB University: Indexing I (Prerequisite course)
- Index Best Practices
Lesson 2: Index Usage Details via Explain
Lesson 3: Optimized Compound Indexes
- Compound Indexes
- The ESR (Equality Sort Range) Rule
- Tips and Tricks for Effective Indexing
- Create Indexes to Support Your Queries
Lesson 4: Wildcard Indexes
- Wildcard Indexes in MongoDB
- Create a WildCard Index on All Fields
- Include or Exclude Fields in a Wildcard Index
- Wildcard Index Restrictions
- Compound Wildcard Indexes (new in 7.0)
Lesson 5: Partial Indexes
Lesson 6: Sparse Indexes
Lesson 7: Clustered Indexes
- Clustered Collections in MongoDB
- Clustered Index Reference
- expireAfterSeconds
- Clustered Collection Examples
Lesson 8: Time Series Collections
- Time Series
- Create a Time-Series Collection
- Add Secondary Indexes to Time-Series Collections
- List Time-Series Collections in a Database
- Set up Automatic Removal
- Time Series Product Overview
Lesson 9: How to Monitor Indexes