explain
Retrieve MongoDB query optimizer execution stats and plan details to analyze and improve query performance.
Instructions
Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>",
"collection": "<collection>",
"method": "<method>"
},
"name": "explain"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | The method and its arguments to run | |
| database | Yes | Database name | |
| verbosity | No | The verbosity of the explain plan, defaults to queryPlanner. If the user wants to know how fast is a query in execution time, use executionStats. It supports all verbosities as defined in the MongoDB Driver. | queryPlanner |
| collection | Yes | Collection name |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | ||
| verbosity | Yes | ||
| explainResult | Yes |