explain
Analyze query execution plans in MongoDB by providing detailed statistics on the chosen query optimizer method for aggregate, find, and count operations. Use to optimize database and collection performance.
Instructions
Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
Input Schema
Name | Required | Description | Default |
---|---|---|---|
collection | Yes | Collection name | |
database | Yes | Database name | |
method | Yes | The method and its arguments to run |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"collection": {
"description": "Collection name",
"type": "string"
},
"database": {
"description": "Database name",
"type": "string"
},
"method": {
"description": "The method and its arguments to run",
"items": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"arguments": {
"additionalProperties": false,
"properties": {
"pipeline": {
"description": "An array of aggregation stages to execute",
"items": {
"additionalProperties": true,
"properties": {},
"type": "object"
},
"type": "array"
}
},
"required": [
"pipeline"
],
"type": "object"
},
"name": {
"const": "aggregate",
"type": "string"
}
},
"required": [
"name",
"arguments"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"arguments": {
"additionalProperties": false,
"properties": {
"filter": {
"additionalProperties": true,
"description": "The query filter, matching the syntax of the query argument of db.collection.find()",
"properties": {},
"type": "object"
},
"limit": {
"default": 10,
"description": "The maximum number of documents to return",
"type": "number"
},
"projection": {
"additionalProperties": true,
"description": "The projection, matching the syntax of the projection argument of db.collection.find()",
"properties": {},
"type": "object"
},
"sort": {
"additionalProperties": {},
"description": "A document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for ascending, -1 for descending).",
"properties": {},
"type": "object"
}
},
"type": "object"
},
"name": {
"const": "find",
"type": "string"
}
},
"required": [
"name",
"arguments"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"arguments": {
"additionalProperties": false,
"properties": {
"query": {
"additionalProperties": true,
"description": "A filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().",
"properties": {},
"type": "object"
}
},
"type": "object"
},
"name": {
"const": "count",
"type": "string"
}
},
"required": [
"name",
"arguments"
],
"type": "object"
}
]
},
"type": "array"
}
},
"required": [
"database",
"collection",
"method"
],
"type": "object"
}