Explain query plan
explainDiagnose slow queries by viewing the database's execution plan and index usage. Optionally execute with analyze=true to measure real timings.
Instructions
Show how the database will execute a SELECT (its query plan) to diagnose slow queries or check index use — use it instead of query when the question is about performance, not data. With analyze=true the statement is actually executed to report real timings (can be slow on big tables). Returns the plan as rows plus a hint: MySQL type=ALL or PostgreSQL 'Seq Scan' means a full table scan (consider an index or a narrower WHERE). SQLite uses EXPLAIN QUERY PLAN. On failure returns isError with 'error: ' (e.g. refused statement, unknown table, SQL error).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SELECT statement to analyze (without EXPLAIN). | |
| analyze | No | true = execute the statement to measure real timings and row counts (EXPLAIN ANALYZE); default false = estimate only, nothing is executed. | |
| database | No | Optional database to use instead of the connection's default (names from `databases`). Omit to use the default. | |
| connection | Yes | Connection name exactly as returned by `connections` (e.g. "shop"). Unknown or unexposed names return an error. |