Provides EXPLAIN ANALYZE workflow for identifying missing indexes, sequential scans, and query plan issues.
94
94%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Provides EXPLAIN ANALYZE workflow for identifying missing indexes, sequential scans, and query plan issues.
This tile defines a systematic workflow for debugging slow PostgreSQL queries using EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON). The agent executes explain plans via MCP execute_sql, parses the JSON output, and identifies four categories of problems: sequential scans on indexed columns, missing indexes on WHERE/JOIN columns, row-estimate vs actual-row deviations, and nested-loop joins on large tables.
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) <query>;| Problem | Plan Signal | Fix |
|---|---|---|
| Seq Scan on indexed column | "Node Type": "Seq Scan" with index present | Investigate planner settings, run ANALYZE |
| Missing index | "Node Type": "Seq Scan" on WHERE/JOIN column | CREATE INDEX CONCURRENTLY |
| Stale statistics | Plan Rows vs Actual Rows ratio > 10x | ANALYZE table_name |
| Nested Loop on large set | "Nested Loop" with inner > 1000 rows | Add join-column index or restructure query |
| Low cache-hit ratio | Shared Read Blocks > Shared Hit Blocks | ANALYZE or tune shared_buffers |
| Field | Purpose |
|---|---|
Node Type | Identifies scan/join strategy |
Plan Rows | Planner's row estimate |
Actual Rows | Real rows returned at execution |
Shared Hit Blocks | Pages read from buffer cache |
Shared Read Blocks | Pages read from disk |
This tile operates as a diagnostic utility invoked on-demand when a query performance issue is identified. It does not create permanent database objects. Other tiles that create indexes or RPCs invoke this tile to verify their output performs correctly.