Explain a query plan
pg_explainInspect a read query’s execution plan without running it; see estimated cost, rows, tables, and sequential scans to understand and prevent slow queries.
Instructions
Show the execution plan of a read query (EXPLAIN) without running it.
Returns the plan plus a summary: estimated cost and rows, tables touched and which of them are read by sequential scan. Use it before running a heavy query and to understand why a query is slow.
analyze=true really executes the query to measure it (EXPLAIN ANALYZE). It is only
available on connections configured with allow_explain_analyze.
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": "pg_explain"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| format | No | text | |
| params | No | ||
| analyze | No | ||
| buffers | No | ||
| verbose | No | ||
| settings | No | ||
| connection | No |