What should I check in explain?
Understand the concept
explain shows how MongoDB plans a query, and execution-statistics modes also show what work was performed. It helps distinguish an efficient index lookup from broad scanning, sorting or excessive document fetching. The goal is to understand why the query does work, not simply whether an index was selected.
Important ideas
-
Compare returned rows with keys and documents examined.
-
Look for collection scans, extra sorting and large scan counts.
-
A covered query gets needed values from the index without fetching documents.
-
When checking coverage, remember that
_idis normally returned unless excluded and may require a document fetch if not covered.
Can you explain it without the notes?
What should I check in explain?
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
explain shows how MongoDB plans a query, and execution-statistics modes also show what work was performed. It helps distinguish an efficient index lookup from broad scanning, sorting or excessive document fetching. The goal is to understand why the query does work, not simply whether an index was selected.
Turn this concept into a clear answer.
- Compare examined data with useful results, and confirm the plan on representative production-sized data.
Adapted from 04_MONGODB_MONGOOSE.md · “What should I check in explain?”. Examples are study fragments; framework behavior can depend on your version.