explain_query
Explain PostgreSQL query execution plans to identify performance bottlenecks and missing indexes. Optionally run with analyze for real timings.
Instructions
Show PostgreSQL's execution plan for a query. Use this to understand query performance and identify missing indexes. analyze=true runs the query to get actual timings (SELECT only). Optionally use server/database/schema params for one-time execution on a different server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL query to explain | |
| analyze | No | Execute query for real timing (SELECT only, blocked for writes) | |
| buffers | No | Include buffer/cache statistics | |
| format | No | Output format | json |
| hypotheticalIndexes | No | Test hypothetical indexes (requires hypopg extension) | |
| server | No | One-time server override. Execute on this server without changing main connection. | |
| database | No | One-time database override. Uses this database for execution. | |
| schema | No | One-time schema override. Sets search_path for this execution only. |