-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Overview
Parse EXPLAIN ANALYZE output and render it as a visual tree in the TUI, with color-coded cost annotations and timing breakdowns, making query optimization intuitive.
Goals
- Visual tree rendering of query execution plans
- Color-coded cost/timing annotations (green = fast, red = slow)
- Identify bottleneck nodes at a glance
- Support both
EXPLAINandEXPLAIN ANALYZEoutput
Proposed Behavior
Activation
- When a query starts with
EXPLAINorEXPLAIN ANALYZE, parse the output into a visual plan instead of showing raw text - Toggle between raw text and visual plan with a keybinding (e.g.,
Ctrl+E)
Visual Plan Rendering
Query Plan (total: 245.32ms)
├─ Nested Loop (cost=0.71..28.53 rows=10) [actual: 2.1ms]
│ ├─ Index Scan on users_pkey (cost=0.29..8.30) [actual: 0.3ms] ✓
│ │ Index Cond: (id = $1)
│ └─ Index Scan on orders_user_id_idx (cost=0.42..2.02) [actual: 1.8ms] ✓
│ Index Cond: (user_id = users.id)
│ Filter: (status = 'active')
│ Rows Removed by Filter: 3
└─ Sort (cost=12.00..12.25 rows=10) [actual: 0.1ms] ✓
Sort Key: orders.created_at DESC
Sort Method: quicksort Memory: 25kB
Color Coding
| Color | Meaning |
|---|---|
| Green | Fast node (< 10% of total time) |
| Yellow | Moderate (10-30% of total time) |
| Red | Slow / bottleneck (> 30% of total time) |
| Cyan | Index usage |
Information Displayed
- Node type (Seq Scan, Index Scan, Hash Join, etc.)
- Estimated vs actual rows (highlight large discrepancies)
- Cost range
- Actual execution time (from ANALYZE)
- Filter conditions and rows removed
- Sort methods and memory usage
- I/O timing (if available via
EXPLAIN (ANALYZE, BUFFERS))
Implementation Suggestions
- Parse the text output of
EXPLAIN (FORMAT TEXT)line by line - Build a tree structure from indentation levels
- Alternatively, use
EXPLAIN (FORMAT JSON)for structured parsing - Render using ratatui's
Paragraphwith styled spans - Add a
PlanNodestruct:{ node_type, cost, actual_time, rows_est, rows_actual, children, details } - Detect EXPLAIN queries in
execute_query()and auto-switch to plan view
Definition of Done
- EXPLAIN output is parsed into a tree structure
- Visual tree renders in the results pane
- Nodes are color-coded by relative cost
- Both EXPLAIN and EXPLAIN ANALYZE are supported
- Toggle between raw and visual view
- Large discrepancies between estimated/actual rows are highlighted
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels