How to get explain output ▾
Run one of the following commands and paste the full JSON output above.
Mongo Pilot (easiest)
- Open Mongo Pilot and connect to your database
- Browse to your collection and run a query using the query builder
- Click the Stats button in the toolbar
- In the explain modal, switch to the Raw JSON tab
- Click Copy JSON and paste it above
mongosh
db.myCollection.find({ status: "active" }).explain("executionStats")
Node.js (official driver)
const plan = await db
.collection("myCollection")
.find({ status: "active" })
.explain("executionStats");
console.log(JSON.stringify(plan, null, 2));
Python (pymongo)
import json
plan = db.my_collection.find({"status": "active"}).explain("executionStats")
print(json.dumps(plan, indent=2, default=str))
Atlas Search ($search) & Vector Search ($vectorSearch)
db.movies.explain("executionStats").aggregate([
{ $search: { text: { path: "title", query: "mongo" } } }
])
db.embeddings.explain("executionStats").aggregate([
{ $vectorSearch: {
index: "vector_index",
path: "embedding",
queryVector: [<...>],
numCandidates: 150,
limit: 10
}}
])
Atlas explain returns a stages array (mongot / Lucene). Use executionStats or allPlansExecution for timing on Lucene nodes.
Search explain ·
Vector explain.
Use executionStats (not queryPlanner) to get per-stage metrics and efficiency data.
