analyzePlan
analyzePlanDiagnose query-plan performance issues with compact structured findings, identifying expensive nodes, full scans, estimation errors, risky nested loops, and disk spills.
Instructions
Diagnose query-plan performance with compact structured findings: expensive nodes, large-table full scans, estimation errors, risky nested loops and disk-sort spills. Use explainQuery when the full textual plan is required. Bind '?'->params, ':name'->namedParams; never mix. E.g. :status -> namedParams={status:'PAID'} — key is the bare name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| params | No | Values for '?' placeholders, in order. | |
| analyze | No | Execute the query to collect runtime stats where supported (default false). | |
| connection | Yes | Database to run against. Call listConnections for valid names; do not guess. | |
| namedParams | No | Values for ':name' placeholders, keyed by name. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Root node of the execution plan. | |
| engine | No | Database engine that produced the result, such as PostgreSQL, Oracle, or SQL Server. | |
| analyzed | Yes | True when the plan includes actual execution metrics, not only estimates. | |
| fullScans | No | Plan nodes that perform full table or index scans and may deserve attention. | |
| nodeCount | Yes | Number of table nodes in the schema graph. | |
| diskSpills | No | Sort or hash nodes that appear to spill to disk. | |
| planningTimeMs | No | Planner time reported by the database, in milliseconds when available. | |
| executionTimeMs | No | Execution time reported by the database, in milliseconds when available. | |
| estimationErrors | No | Plan nodes where actual rows differ materially from estimated rows. | |
| riskyNestedLoops | No | Nested-loop nodes that may be expensive because the outer side is large. | |
| topExpensiveNodes | No | Plan nodes ranked as most expensive by cost or actual time. |