Skip to content

explain_sql

MCP tools › Databases

Show the execution plan of one statement as a tree (operation, table/index, conditions, estimated rows and cost; with analyze=true also actual rows, time and loops) plus hints such as full scans of big tables and misestimates. Each step also has properties (every field the database reports for it, by its own name), startup_cost, cost_share (its total cost as a part 0..1 of the whole plan's) and its own hints. analyze runs the statement inside a transaction that is rolled back, also a read; schema changes are refused. Needs read-schema; analyze also needs the statement's own permission.

Its results carry text from database: the client is told to treat that as data, never as instructions.

Capabilitydatabase.explain_sql
AreaDatabases
Accesschanges database
Reachesdatabase, network
Rightsssh, database-permission, trusted-project
Dry runnone

Arguments

ArgumentTypeDescription
connectionrequiredstringConnection name from list_connections.
sqlrequiredstringExactly one statement.
analyzebooleanRun the statement and measure it (default false). Data changes are rolled back.

Call it from a shell

ferris-idea call runs one tool with the rights and safe mode of ferris-idea mcp. Replace the folder and the placeholder values.

Terminal window
ferris-idea call ~/my-project explain_sql '{"connection":"<string>","sql":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"connection",
"sql"
],
"properties": {
"connection": {
"description": "Connection name from `list_connections`.",
"type": "string"
},
"sql": {
"description": "Exactly one statement.",
"type": "string"
},
"analyze": {
"description": "Run the statement and measure it (default false). Data changes are rolled back.",
"type": [
"boolean",
"null"
]
}
}
}