explain_query
Show a read-only SELECT query plan with real row counts and timings to diagnose slow queries, then validate rewrites with compare_queries.
Instructions
Show the query plan for one read-only SELECT, with real row counts and timings where the database gives them (PostgreSQL: EXPLAIN ANALYZE, which runs the query; everything is rolled back). Same checks as run_query. Use it to see why a query is slow before rewriting it, then check your rewrite with compare_queries.
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 | One read-only SELECT (or WITH ... SELECT) written against the DDL select_schema returned. Writes, DDL and multiple statements are refused, as is any table or column this caller may not read. | |
| roles | No | The caller's roles or groups, e.g. ['finance', 'payroll']. Objects and columns restricted to a role are visible only when it is listed here. Omitted = no roles. | |
| principal | No | Who is asking, as an identity string such as 'okta:jdoe'. Pass it whenever you know the user: visibility is decided for this identity. Omitted = anonymous, which sees only unrestricted objects. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |