Background
MongoDB’s explain("executionStats") output is the primary diagnostic for query performance, but the raw JSON is verbose, deeply nested, and formatted differently across engine versions. The output structure for a simple covered index query on MongoDB 4.4 looks nothing like the equivalent plan on MongoDB 7 when the Slot-Based Execution (SBE) engine is active. Developers either learn to navigate the raw JSON manually — which takes time and practice — or they miss findings that are present but not obvious.
The goal was a tool that removes that barrier: paste an explain plan, get a clear visual tree and specific, evidence-backed findings immediately. No account, no sign-up, no data leaving the browser.
What the tool does
Plan analysis
The analyzer accepts explain("executionStats") output from find() queries and aggregation pipelines. It detects the MongoDB version and engine type automatically from the plan structure and routes parsing accordingly.
The visual tree renders each stage — IXSCAN, COLLSCAN, FETCH, SORT, PROJECTION, $lookup, and others — as a node with its key execution statistics displayed inline. Nested aggregation stages are expanded as a tree rather than as collapsed JSON.
Findings engine
The tool surfaces specific findings rather than raw numbers alone. Findings are generated from the actual metrics in the plan:
- COLLSCAN on a large collection: Flagged when a
COLLSCANstage is present with a highnReturnedtototalDocsExaminedratio, with guidance on index candidates based on the query predicate. - Low index selectivity: Flagged when
keysExaminedsignificantly exceedsnReturned, indicating the index is not selective enough for the query shape. - Covered query opportunity: Flagged when
totalDocsExaminedis non-zero but a covered query is achievable by projecting only indexed fields. - Covered query confirmed: Flagged when
totalDocsExamined = 0, confirming the query is satisfied entirely from index data. - Document examination ratio: The ratio of
totalDocsExaminedtonReturnedis surfaced for every plan. A ratio of 1:1 is ideal; a high ratio indicates the query reads more documents than it returns, pointing to a missing or inappropriate index.
SBE engine support
MongoDB 5 introduced the Slot-Based Execution engine as an opt-in for eligible queries, and MongoDB 6 expanded its coverage. The SBE plan format uses different stage names (seek, ixseek, nlj, traverse) and a different tree structure from the classic engine. Most available tools at the time did not handle SBE output — they either produced parse errors or silently dropped stages.
The parser handles both formats and presents them in a consistent tree layout regardless of which engine produced the plan.
Additional utilities
- SQL to MongoDB converter: Translates common SQL
SELECTpatterns —WHERE,GROUP BY,ORDER BY,LIMIT,JOINas$lookup— into equivalent MongoDB query or aggregation syntax. - ObjectId converter: Decodes MongoDB ObjectId values to their embedded timestamp, machine identifier, and process counter components.
Architecture
The tool is entirely client-side JavaScript. There is no server component, no backend API, and no telemetry or data collection. When a user pastes an explain plan, the JSON is parsed and analyzed in the browser. The plan never leaves the user’s machine.
This was a deliberate design decision. Explain plans from production systems often contain collection names, index names, field names, and query predicate values that reflect real data schemas. Transmitting these to a third-party server would be a privacy concern for many teams. A purely client-side architecture removes that concern entirely.
Lessons Learned
Parsing MongoDB explain output is not trivial: The output format has changed meaningfully across major versions and is not formally documented as a stable API. Handling edge cases — partial plans from sharded clusters, explain output from $graphLookup, plans with rejected candidates — required building against real explain output from multiple MongoDB versions rather than relying on documentation alone.
SBE stage names are not self-describing: The classic engine stage names (IXSCAN, FETCH, COLLSCAN) map naturally to English descriptions. SBE stage names (seek, traverse, nlj) require contextual interpretation. The tool translates these into meaningful labels while preserving the original stage name for reference.
Findings need specificity to be useful: Early versions surfaced generic observations — “this query does a collection scan.” This is not actionable on its own. The findings were rewritten to include the exact metric that triggered the finding and a concrete investigation path — for example, the specific keysExamined to nReturned ratio and what it implies about index selectivity.
Client-side architecture simplifies deployment: With no server to operate, the entire tool is a static site. There are no databases, no secrets, no session state, and no infrastructure to maintain. The operational cost is effectively zero.
Notes
mongodbplan.com is an independent tool. It is not affiliated with MongoDB, Inc.