Explain verbosity modes
Parent: MongoDB Query Optimization Tooling: Compass Explain, Atlas Query Insights and Performance Advisor · Published reference · snapshot 2026-10-20 · skill ranked-92d6787e
↓ Facts as markdownall context files
Source-anchored research for Explain verbosity modes. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Structure and components
- MongoDB provides three explain verbosity modes: `queryPlanner`, `executionStats`, and `allPlansExecution`. The selected mode determines whether output contains completed execution statistics and whether it includes plan-selection trial data. (high confidence) [source]
How it works
- The database `explain` command defaults to `allPlansExecution`, while mongosh `cursor.explain()` and `db.collection.explain()` default to `queryPlanner`. Passing the verbosity explicitly avoids different output when moving between the command and helper methods. (high confidence) (verified as of 2026-10-14) [source]
How-to and procedures
- Use `queryPlanner` to inspect the winning plan structure and considered alternatives. Use `executionStats` to assess the completed winning plan with counters such as `nReturned`, `totalKeysExamined`, and `totalDocsExamined`. Use `allPlansExecution` when candidate-plan trial results are needed; the rejected candidates' execution data is partial. (high confidence) [source]
Facts and statements
- `queryPlanner` returns planner information without the completed `executionStats` section. `executionStats` executes the winning plan to completion and adds full-run statistics. `allPlansExecution` includes that winning-plan data plus partial plan-selection statistics for candidate plans, including rejected plans. Those candidate figures are trial data, not completed-query totals. (high confidence) (verified as of 2026-10-14) [source]
- MongoDB Compass's Explain Plan modal presents a visual plan tree and a query-performance summary with winning-plan counters such as documents returned, documents examined, and index keys examined; Raw Output exposes the JSON explain details. (medium confidence) (verified as of 2026-10-19) [source]
- Do not treat `executionStats.executionTimeMillis` as a direct measure of application latency. Explain ignores existing plan-cache entries and does not cache the winning plan; the reported time includes plan selection and query execution but excludes network transmission, so steady-state cached queries can complete faster. (high confidence) (verified as of 2026-10-14) [source]
- `queryPlanner` runs the query optimizer and returns planning information for the evaluated operation, including its winning plan and rejected plans. It does not return completed `executionStats` for the winning plan. (high confidence) [source]
- `executionStats` runs the optimizer-selected winning plan to completion and adds execution counters such as `nReturned`, `totalKeysExamined`, and `totalDocsExamined`. For write operations, explain reports the changes that would occur without applying them to the database. (high confidence) [source]
- `allPlansExecution` returns completed execution statistics for the winning plan plus candidate-plan statistics captured during plan selection. Candidate-plan trial data is not equivalent to full-completion statistics for every rejected plan. (high confidence) [source]
- MongoDB does not allow `executionStats` or `allPlansExecution` explain for an aggregation pipeline containing `$out`; run `queryPlanner` or explain the stages before `$out` instead. (high confidence) (verified as of 2026-10-20) [source]
Children
- No children recorded.