explain
Returns a SQL statement's execution plan as an indented tree with costs, estimated/actual rows and times, plus index suggestions for filtered full scans.
Instructions
Returns the plan of one SQL statement: its steps as an indented tree with cost, estimated rows and, with analyze=true, actual rows and times (or JSON with format=json), then index suggestions for filtered full scans of large tables. Without analyze the statement does not run. With analyze it runs and what it changes is rolled back; on read_only connections only statements that change nothing are explained, and analyze needs PostgreSQL, MySQL, MariaDB or SQLite. max_bytes (default 32768) and timeout_seconds (default 30) work as in run_query.
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": {
"connection": "<connection>",
"sql": "<sql>"
},
"name": "explain"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One SQL statement. | |
| format | No | `text` (an indented tree, the default) or `json`. | |
| analyze | No | Run the statement for real rows and times (`EXPLAIN ANALYZE`); what it changes is rolled back. Default false: the planner's estimates, without running it. | |
| max_bytes | No | Bytes of output at most (default 32768, up to 1048576). | |
| connection | Yes | The connection's name, as `list_connections` shows it. | |
| timeout_seconds | No | Seconds the request may take before it is cancelled (default 30, up to 300). |