explain_query
Show a SQL query's execution plan with cost estimates to diagnose performance, optionally running SELECTs for real statistics or simulating hypothetical indexes.
Instructions
Show the execution plan of a SQL query with cost estimates. A query with $1-style placeholders (as in query statistics) is explained with a generic plan. Hypothetical indexes need the hypopg extension.
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": {
"sql": "<sql>"
},
"name": "explain_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL query to explain | |
| analyze | No | Run the query to show real execution statistics; only for a SELECT that passes the read check, inside the time limit | |
| hypothetical_indexes | No | Hypothetical indexes to simulate with hypopg; they are removed before the call ends |