A worked example, rendered from real sample data. Sign in to run the tool on your own input.
SELECT u.id, u.name, COUNT(o.id) as orders FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.active = true GROUP BY u.id, u.name ORDER BY orders DESCQuery Execution Explanation & Index Analysis
══════════════════════════════════════════════════
1. EXECUTION PLAN (estimated):
└─ Seq Scan on table (cost=0.00..100.00)
Filter: condition
Estimated rows: 50 / Actual rows: 48
2. INDEX ANALYSIS:
✓ Can use index on: id (if filtering on id)
✗ Missing index on: status, created_at
• Full table scan if no WHERE clause
3. OPTIMIZATION OPPORTUNITIES:
• Add composite index: (status, created_at DESC)
• Use index-only scan by selecting indexed columns
• Consider partitioning on date range
4. ESTIMATED COSTS:
Without Index: ~5000 I/O operations
With Index: ~50 I/O operations
Improvement: ~100x faster
5. ROW ESTIMATES:
└─ Expected output: 50-100 rows
└─ Memory usage: ~50KB
└─ Execution time: 10-50ms
Explain SQL query execution with index analysis and optimization hints. Part of the DevTools Surf developer suite. Browse more tools in the Developer Utilities collection.