explain_query
Analyze MongoDB query execution plans to identify indexes used, documents examined, and execution stages. Optimize slow queries by understanding query performance and behavior.
Instructions
Get the execution plan for a query.
Helps understand:
How MongoDB will execute the query
Which indexes will be used
Number of documents examined
Execution stages and timing
Use this to optimize slow queries.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
collection | Yes | Collection name | |
database | No | Database name (optional if default database is configured) | |
filter | Yes | MongoDB query filter to explain | |
projection | No | MongoDB projection (optional) | |
sort | No | MongoDB sort specification (optional) |
Input Schema (JSON Schema)
{
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"database": {
"description": "Database name (optional if default database is configured)",
"type": "string"
},
"filter": {
"description": "MongoDB query filter to explain",
"type": "object"
},
"projection": {
"description": "MongoDB projection (optional)",
"type": "object"
},
"sort": {
"description": "MongoDB sort specification (optional)",
"type": "object"
}
},
"required": [
"collection",
"filter"
],
"type": "object"
}