Analyze query plan
analyze_query_planSummarizes a query's execution plan: estimated cost, rows, node types, and sequential scans. Optionally analyze with I/O timing and buffer statistics for actual performance.
Instructions
Summarise a query's execution plan: total estimated cost, estimated rows, node types used, and any sequentially-scanned tables. Set io=true to run EXPLAIN (ANALYZE, BUFFERS, TIMING) instead of the plan-only variant — adds actual_total_time_ms, shared_blocks_read/hit, io_read_time_ms, io_write_time_ms, and (PG 19) aio_read_blocks / aio_write_blocks rolled up across the plan tree. Reasoning about AIO needs io=true.
Example: analyze_query_plan(sql='SELECT * FROM orders WHERE customer_id = 42', io=true)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| io | No | ||
| sql | Yes | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| node_types | Yes | ||
| total_cost | Yes | ||
| actual_rows | No | ||
| estimated_rows | Yes | ||
| aio_read_blocks | No | ||
| io_read_time_ms | No | ||
| aio_write_blocks | No | ||
| io_write_time_ms | No | ||
| sequential_scans | Yes | ||
| shared_blocks_hit | No | ||
| shared_blocks_read | No | ||
| actual_total_time_ms | No |