explain_query
Run EXPLAIN (ANALYZE, BUFFERS) on a SELECT query to find where time is spent and get fixes for seq scans, bad row estimates, disk sorts, and repeated nested loops.
Instructions
Run EXPLAIN (ANALYZE, BUFFERS) on one SELECT query and diagnose the plan.
The query runs in a read-only transaction that is rolled back. Returns total time,
the nodes where time was actually spent, and findings such as wasteful sequential
scans, row misestimates, sorts spilling to disk and repeated nested-loop scans,
each with a suggested fix.
Args:
sql: A single SELECT / WITH query.
analyze_query: False shows the estimated plan without executing the query.
timeout_ms: Abort the query after this many milliseconds.
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 | ||
| timeout_ms | No | ||
| analyze_query | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |