- Docker-compose Postgres 16
- Enable pg_stat_statements, auto_explain extensions
- Create roles (profiler_ro, profiler_sb)
- Basic health checks and connection testing
- Scaffold Fiber + Cobra projects
- Environment/config setup
- pgx pool initialization
- Basic health endpoint
- Create demo tables (users, orders, order_items, events)
- Insert realistic dummy data (30 users, 30 orders, 51 items, 34 events)
- Add intentional performance problems:
- Missing index on users.email β seq scan
- Missing index on orders.user_id β seq scan
- Missing composite index on (user_id, status) β bad joins
- Correlated subqueries β inefficient queries
- Text search without index β slow LIKE queries
- JSON queries without GIN index β slow JSON ops
- Execute slow queries 10x each to build pg_stat_statements data
- Verify pg_stat_statements capturing slow queries (8.7ms avg for worst query)
- CLI:
init,scan,bottleneckscommands - Wire
scanto call API endpoints - Basic command structure and help
- Create
/ingestmodule to pull pg_stat_statements - Join with pg_class, pg_index for table/index metadata
- Persist to meta store (create simplified schema)
- Build query fingerprinting logic
- Create data access layer for query stats
-
/http:GET /bottlenecks,GET /queries/:idendpoints - Server-rendered dashboard (HTMX) with top N bottlenecks
- DTOs for bottlenecks, query detail
- Simple plan facts chips (Seq/Index, est vs act)
- Create
/parsemodule for query normalization - Implement query fingerprinting (hash-based)
- Optional: AST parsing via pg_query_go (skip if time-pressed)
- Build query similarity detection
- Wire rules to UI + CLI output
- Table of recommendations with "Why / DDL / Risk" columns
- HTMX integration for dynamic updates (CLI output ready)
- Basic styling and layout (CLI formatting complete)
- Create
/rulesmodule with heuristics:- Missing index detection (seq scan on big tables)
- Composite join index suggestions
- Correlated subquery detection (regex/AST)
- Redundant index detection
- Cardinality skew detection (est vs actual rows)
- Create
/recommendmodule:- DDL generation for index recommendations
- Rationale generation (plain English explanations)
- Confidence scoring (0.0-1.0)
- CLI demo script
scanβbottlenecks - Minimal README documentation
- Error handling and logging
- Basic testing framework
- Smoke test rules engine on seeded data
- Adjust detection thresholds based on results
- Validate recommendations make sense
- Performance tune the analysis pipeline
- End-to-end testing
- Performance validation
- UI responsiveness testing
- CLI output formatting
- Create
/simulatemodule - Implement baseline EXPLAIN (ANALYZE, BUFFERS) capture
- Add hypopg extension for hypothetical indexes
-
/features: TF-IDF implementation -
/ml: K-Means families - Label via table/verb bigrams
- Implement hypopg_create_index() workflows
- Re-run EXPLAIN with hypothetical indexes
- Compute improvement percentages
- Capture before/after plan diffs
- Add cleanup logic for hypopg state
- Per-family MAD/IQR anomalies
- Expose tags in
/queries/:id+/bottlenecks - UI polish: Before/After cards with %Ξ badge
- Plan snippet diff (node type change badges)
- Add guards: timeouts, concurrency caps
- Implement rollback on errors
- Create unit tests for rules + simulate
- Add error handling and logging
- Confidence & risk notes in UI
- Update CLI:
simulatecommand - Improve table formatting
- Error handling and user feedback
- Add optional mode:"real" on sandbox schema
- Implement safe real-index testing
- Add safety checks and rollback
- Real mode UI controls
- Safety warnings and confirmations
- Progress indicators for long operations
- Implement caching for schema/stat calls (2-5 min TTL)
- Add pg_locks summary for contention detection
- Add "contention suspected" labels
- Implement EXPLAIN timeouts and rate limits
-
/chat: template-grounded answers - Pulls query metrics, plan facts, and recommended DDL
- Returns cited explanation (no hallucinations)
- Q&A interface integration
- Finalize Make targets: up/init/seed/scan/demo/test
- Stabilize detection thresholds and defaults
- Performance optimization
- Docs: README (90-sec Quick Start)
- ARCHITECTURE (diagram + flow)
- DEMO (script + screenshots/GIFs)
- User interface polish
- Run full dry-run
- Capture screenshots
- Trim logs and optimize
- Demo rehearsal: seed β scan β bottleneck β simulate β chat
- Performance validation on acceptance targets
- Final UI/UX polish
- Documentation review
MAJOR BREAKTHROUGH: AI-Powered Recommendations System Implemented! π€
- β 0-2h: Docker Setup (PostgreSQL 16 + extensions + roles)
- β 2-5h: Demo Schema + Slow Queries (4 tables, 100+ records, performance problems)
- β 5-9h: Ingest & API Foundation (pg_stat_statements collection + metadata joins)
- β 9-14h: Parse & UI Integration (query normalization + CLI output)
- β 14-20h: Rules Engine v1 (5 detection types + DDL generation)
- β 20-24h: Testing & Tuning (smoke tests + performance validation)
- π€ AI Integration: Azure OpenAI GPT-4.1 with structured prompts
- π Advanced Logging: [timestamp] [file:line] [level] with stack traces
- π Smart Fallback: Graceful degradation when AI unavailable
- π Production Ready: Real API calls with token tracking
- β‘ Live Testing: Working with real seeded data
- β
/ingestmodule: pg_stat_statements collection with metadata joins - β
/parsemodule: Query normalization and fingerprinting - β
/rulesmodule: AI + heuristic rule engine with 5 detection types - β
/recommendmodule: Template-based fallback system - β AI Integration: Azure OpenAI GPT-4.1 for intelligent recommendations
- β Comprehensive logging: [timestamp] [file:line] [level] with stack traces
- β Database roles and connection management issues fixed
- π€ AI-Powered Recommendations: Real OpenAI API integration with structured prompts
- π Smart Fallback System: Graceful degradation to heuristics when AI unavailable
- π Complete Rule Engine: Missing indexes, redundant indexes, correlated subqueries, cardinality issues, join optimization
- π Production Logging: Full debug capability with file/line/traceback
- β‘ Live Testing: Working with real seeded data and pg_stat_statements
cli/
βββ main.go # Entry point with .env support
βββ cmd/ # 4 CLI commands
β βββ root.go # Base command
β βββ scan.go # Database scanning
β βββ bottlenecks.go # Detailed analysis
β βββ serve.go # Web server (placeholder)
βββ internal/ # 7 core modules
βββ ai/openai.go # π€ Azure OpenAI integration
βββ db/connection.go # Database connections
βββ ingest/stats.go # pg_stat_statements collection
βββ logger/logger.go # Production logging
βββ parse/fingerprint.go # Query normalization
βββ recommend/generator.go # Fallback templates
βββ rules/detector.go # AI + heuristic engine
βββ store/models.go # Data structures
deploy/
βββ docker-compose.yml # PostgreSQL 16 + profiling
βββ postgresql.conf # Custom configuration
βββ init/ # Database setup
β βββ 01-extensions.sql # pg_stat_statements
β βββ 02-roles.sql # profiler_ro, profiler_sb
βββ seed.sql # Demo data + slow queries
βββ Makefile # Database operations
- β AI-Powered Analysis: Real OpenAI API calls with structured prompts
- β 5 Rule Types: Missing indexes, redundant indexes, correlated subqueries, cardinality issues, join optimization
- β Production Logging: [timestamp] [file:line] [level] with stack traces
- β Smart Fallback: Graceful degradation when AI unavailable
- β Live Testing: Working with real seeded data and pg_stat_statements
- β
CLI Interface:
scanandbottleneckscommands with detailed output
- HTTP API Wrapper: Expose existing backend via REST endpoints
- Web Dashboard: Server-rendered UI consuming the API
- CLI Integration: Wire existing CLI to web server
- Scan 100 queries β€ 2s (warm cache)
- Top recs precision β₯ 80% show >30% simulated speedup
- Simulator (hypopg) β€ 1.5s round-trip per query
- UI first content paint β€ 1s
- β 30 users with realistic names/emails
- β 30 orders across multiple statuses
- β 51 order items with product names
- β 34 events with JSON data
- β Multiple slow query patterns in pg_stat_statements
- β Worst query: 8.7ms avg (correlated subquery + missing indexes)