Choosing the right explain() verbosity
coreintermediateexplain("queryPlanner") — the default — shows the winning plan's shape with no execution. explain("executionStats") actually runs the query and adds real numbers for the winner. explain("allPlansExecution") adds those same real numbers for every candidate, useful specifically when the winner's choice itself is in question.
Think of it as
Pick verbosity by what question you're actually asking: "what plan would run" needs only queryPlanner; "how well did it actually perform" needs executionStats; "why did this plan win over that one" needs allPlansExecution. Reaching for the highest verbosity by default costs real execution time on every candidate, so matching the level to the question saves work as well as clarifying intent.
What we're doing: Match three real investigation questions to the correct verbosity level, showing the cost/benefit reasoning explicitly.
- 2
- A yes/no question about plan shape does not need real execution numbers — queryPlanner answers it for free.
- 5
- A "why did X win over Y" question specifically needs the comparative data only allPlansExecution provides — the other two modes cannot answer it.
Why this works: Choosing verbosity by the actual question being asked, rather than defaulting to the highest level "to be safe," keeps performance investigation itself cheap and its output focused on what is actually needed.
Defaulting to allPlansExecution for routine index-shape checks
Wrong
Better
What you see: Routine query investigation on a large or slow collection takes noticeably longer than it needs to, because every check ran every candidate plan's full trial.
Why: allPlansExecution's cost is proportional to the number of candidate plans, all executed — most investigation questions ("does this use an index," "how much work did it do") are answered fully by a cheaper mode, and only genuinely comparative questions need the more expensive one.
- queryPlanner: no execution, plan shape only — cheapest — "what would run"
- executionStats: no execution, real numbers — runs the winner — real numbers
- allPlansExecution: executes every candidate, real numbers — runs every candidate — "why did this win"
Verbosity → what it costs → what it answers
Together
Remember: queryPlanner: plan shape, no execution. executionStats: runs the winner, real numbers. allPlansExecution: runs every candidate — reserve it for "why did this plan win" questions specifically, since it costs the most.
See also: explain basics · scan to return ratios

