
Database Schema Optimizer
Analyze database schemas for performance issues and generate migration scripts
What You Can Do
Audit your entire database schema to detect structural inefficiencies that degrade performance. The skill identifies denormalization problems, missing or poorly designed indexes, N+1 query patterns, referential integrity risks, and partitioning opportunities—then generates executable migration code tailored to your database system (PostgreSQL, MySQL, or SQLite). You'll get prioritized recommendations that address both immediate bottlenecks and long-term design improvements.
Features
identifies redundant data and update anomalies caused by improper schema design
flags missing indexes and suggests optimal index strategies for query performance
spots inefficient query patterns and recommends eager-loading solutions
checks referential integrity and relationship constraints for data consistency
suggests table partitioning strategies for large datasets based on access patterns
produces executable SQL migration code for PostgreSQL, MySQL, or SQLite
quantifies expected query performance improvements from recommendations
provides application-level changes (eager loading, caching) alongside schema fixes
Example Output
Input: A user pastes their PostgreSQL schema with 8 tables, user and post relationships, and slow query logs.
Output:
## Critical Issues (Fix First)
1. Missing composite index on posts(user_id, created_at) — estimated 340% query speedup
Migration: CREATE INDEX idx_posts_user_time ON posts(user_id, created_at);
2. N+1 pattern detected: Comments table missing user_id denormalization
Recommendation: Add user_id + username columns to comments for eager-loading
Migration script provided with backfill strategy
## Schema Improvements
- Normalize 'user_roles' (currently comma-separated in users table)
- Partition posts table by year on created_at (current: 45M rows)
## Generated Migrations
[Full executable migration scripts with rollback procedures]
What's Included
- SKILL.md: core analyzer instructions and schema assessment framework
- Schema audit template: structured checklist for database analysis
- Migration script templates: boilerplate SQL for PostgreSQL, MySQL, SQLite
- N+1 detection patterns: code examples and eager-loading strategies
- Index design worksheet: step-by-step guide for evaluating indexing strategies
Who It's For
- Database administrators managing legacy systems or performance issues
- Backend engineers optimizing application database performance
- Technical architects designing schemas for new systems
- DevOps engineers planning database infrastructure upgrades
- Data engineers working with OLTP systems requiring query optimization
Best For
- Legacy database health assessments and performance audits
- Identifying root causes of slow queries before profiling individual statements
- Pre-production schema validation and optimization
- N+1 query detection and eager-loading strategy planning
- Migration planning for database refactoring and scaling







