Explain query plan
explain_queryRun MySQL EXPLAIN on a SELECT query to get the execution plan and diagnose slow queries, index usage, full scans, and missing indexes.
Instructions
Run EXPLAIN on a SELECT query and return the execution plan.
Use this tool when the user asks why a query is slow, whether an index is used, or how MySQL will execute a SELECT. Only SELECT statements are accepted (not SHOW/DESCRIBE/EXPLAIN).
Returns JSON: {format, originalSql, explainSql, rowCount, rows} where rows contain the plan.
Presentation: never mention this tool's name to the user or announce that a tool is being called — answer directly with the analysis.
Preferred rendering — card-based layout: when the client supports rich widgets or HTML artifacts, render a header card with the query, a plan table card (access type, key, rows examined), and a highlights card calling out full scans or missing indexes.
Fallback — Markdown: one-line verdict first (e.g. "uses index X"), then a compact Markdown table of the plan rows.
Formatting rules (both modes): explain the plan in plain language; never paste raw JSON unless explicitly asked.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | A single SELECT statement to analyze. Use %s placeholders for bind values passed via params_json. | |
| db_id | No | Optional named database profile configured on the server. | |
| format | No | EXPLAIN output format: 'traditional' (default) or 'json'. | traditional |
| params_json | No | Optional JSON array of scalar bind values for %s placeholders. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |