MongoDB & MongooseInterview preparation
Intermediate·Concept·2 min read

What should I check in explain?

Practice this question

Definition:

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.

Key points:

  • 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 _id is normally returned unless excluded and may require a document fetch if not covered.

Interview point:

  • 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?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.