Skip to content
Monghoul
Free tool · Runs in your browser

MongoDB Explain Visualizer

Paste the output of .explain('executionStats') to get the winning plan, the stage-by-stage pipeline, efficiency metrics, compound index suggestions, and a list of things worth fixing. Nothing leaves your browser.

Paste explain output
Output of .explain('executionStats') as JSON.
Try a sample
Waiting for input

Run db.collection.find(…).explain('executionStats') in the mongo shell or Monghoul and paste the JSON output on the left. Or load one of the samples above to see what the visualizer produces.

What the visualizer shows

Winning plan & stage pipeline

Every COLLSCAN, IXSCAN, FETCH, and SORT in execution order, with per-stage timings, examined and returned counts, index names, and index bounds.

Aggregation pipelines

Walks through $match, $lookup, $group, $facet, $unionWith and their sub-pipelines. Document counts between stages make it obvious where the data shrinks.

ESR-ordered index suggestions

When a query uses a collection scan or in-memory sort, the visualizer generates a compound index that follows Equality, then Sort, then Range. Copy-paste ready.

Performance insights

Automatic warnings for collection scans, in-memory sorts, disk spills, low efficiency ratios, and other common query-optimizer smells.

Rejected plan candidates

The alternatives the query planner considered before picking the winner. Useful when you want to understand why a particular index got chosen.

100% client-side

Parsing runs in your browser. Your explain output, query filters, and field names never hit a server.

How to get an explain plan

Append .explain('executionStats') to any query in the mongo shell or a GUI like Monghoul.

Find query
db.users
  .find({ status: 'active', age: { $gt: 18 } })
  .explain('executionStats')
Aggregation
db.orders.explain('executionStats')
  .aggregate([
    { $match: { status: 'shipped' } },
    { $lookup: { /* ... */ } }
  ])

Frequently asked questions

What is a MongoDB explain plan?

An explain plan shows exactly how MongoDB executes your query: which index it chose, how many documents it examined, how long each stage took. It's the first thing to look at when a query is slow.

How do I generate an explain output?

Append .explain('executionStats') to your query in the mongo shell or in Monghoul. For aggregations, call db.collection.explain('executionStats').aggregate([...]). The JSON output is what you paste here.

Which verbosity should I use?

Use executionStats for almost every case. It gives you real stage timings and examined/returned counts. queryPlanner alone doesn't include runtime data. allPlansExecution adds profiles for each candidate plan the optimizer considered.

Does this send my data anywhere?

No. Parsing and rendering happen entirely in your browser. Nothing you paste is sent to a server. Still, redact sensitive filter values before pasting if they appear in your query.

How do I read the suggested indexes?

Suggestions follow the ESR rule: Equality fields first, then Sort, then Range. That's the order MongoDB needs to fully use a compound index. Copy the db.collection.createIndex(...) command and run it against your cluster.

What’s the difference between docs examined and nReturned?

docsExamined is how many documents MongoDB had to read from storage. nReturned is how many matched the filter. When they diverge a lot, the query is doing wasted work. Usually the sign of a missing or poorly matched index.

Do this every time you touch a slow query

This exact visualizer ships inside Monghoul (the desktop MongoDB GUI), right next to the query editor. Re-run explain, see the new plan, never leave the app.

Download Monghoul