MongoDB Explain Analyzer
Paste the output of explain("executionStats"). dbCove AI finds the stage that costs the time, says why and gives the index that fixes it.
How to get the plan in MongoDB
In mongosh:
db.orders.find({ customerId: "C-20931" }).sort({ createdAt: -1 }).explain("executionStats")The pipeline's plan and counts:
db.orders.explain("executionStats").aggregate([ ... ])With the plans the optimizer rejected:
db.orders.find({ ... }).explain("allPlansExecution")What it looks for in a MongoDB plan
A collection scan where an index would read only the matching documents.
totalKeysExamined and totalDocsExamined against nReturned. The ratio is the waste.
A SORT stage that an index in the sort order would remove.
Compound index fields in the order that lets one index serve the filter and the sort.
Why the winning plan won, and whether a better index already exists.
This was one statement. dbCove watches all of them.
On your own databases dbCove AI has the history of every plan, every wait and every change, so it can tell you why a plan flipped, not only that it is slow. Free for 2 databases of each engine.
Questions
Is what I paste kept?
It is sent to our AI provider to be explained and kept by us for up to 12 months to improve the tools; the AI provider does not keep it or train on it. Remove passwords and personal data before you paste.
Which verbosity should I use?
executionStats. It runs the query and reports keys and documents examined for every stage. queryPlanner shows only the chosen plan, with no counts.
Does it read aggregations?
Yes. Paste the explain output of the pipeline; the $match and $sort stages that reach the collection are where an index helps.
Which versions does it read?
MongoDB 4.4 and later, replica sets and sharded clusters, including MongoDB Atlas.