-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
Summary
Build query optimization suggestion engine to help developers write performant SQL.
Problem
Parser doesn't provide optimization guidance - developers miss performance opportunities.
Action Items
-
Implement analysis engine detecting:
- Missing indexes: WHERE clauses without index hints
- SELECT * anti-pattern: Suggest explicit column lists
- N+1 query patterns: Detect loops that could be JOINs
- Cartesian products: Missing JOIN conditions
- Subquery optimization: Suggest JOIN alternatives
- INDEX usage: Recommend index creation
- Unused columns: In ORDER BY, GROUP BY
- Function on indexed column: Prevents index usage
-
Suggestion system with:
- Problem description
- Suggested fix with code example
- Performance impact estimate
- Rationale
-
CLI integration:
gosqlx optimize query.sql gosqlx optimize --explain query.sql
-
API for programmatic use
Acceptance Criteria
- 15+ optimization rules
- Suggestions with actionable code examples
- Performance impact estimates
- Documentation for each rule
- Low false positive rate (< 10%)
Technical Details
Priority: Low
Effort: Large (80h)
Phase: Phase 7 - Advanced Features
Dependencies: FEAT-002 (Linting rules engine)
Example Output
Optimization Opportunity: SELECT * anti-pattern
Line 1: SELECT * FROM users WHERE active = true
Problem: SELECT * fetches all columns, reducing performance
Suggestion: SELECT id, name, email FROM users WHERE active = true
Impact: ~40% faster query execution, reduced network traffic