database-optimizer-skill/SKILL.md
Use when user needs database query optimization, performance tuning, index strategies, execution plan analysis, or scalability across PostgreSQL, MySQL, MongoDB, Redis, and other database systems.
npx skillsauth add 404kidwiz/claude-supercode-skills database-optimizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Provides expert database performance tuning and optimization across major database systems (PostgreSQL, MySQL, MongoDB, Redis) specializing in query optimization, index design, execution plan analysis, and system configuration. Achieves sub-second query performance and optimal resource utilization through systematic optimization approaches.
Invoke this skill when:
Do NOT invoke when:
| Symptom | First Action | Tool | |---------|--------------|------| | Query >100ms | EXPLAIN ANALYZE | Execution plan review | | High CPU | pg_stat_statements | Find top queries | | High I/O | Index review | Missing index detection | | Connection exhaustion | Pool tuning | PgBouncer/connection limits | | Replication lag | Write optimization | Batch operations |
Query Performance Issue
│
├─ WHERE clause filtering?
│ └─ Create B-tree index on filter columns
│
├─ JOIN operations slow?
│ └─ Index foreign key columns
│
├─ ORDER BY/GROUP BY expensive?
│ └─ Include sort columns in index
│
├─ Covering index possible?
│ └─ Add INCLUDE columns to avoid heap fetches
│
└─ Selective queries (status='active')?
└─ Use partial index with WHERE clause
Scenario: Production query taking 3.2s, needs to be <100ms
Step 1: Capture baseline with EXPLAIN ANALYZE
EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
SELECT u.id, u.email, COUNT(o.id) as order_count, SUM(o.total) as total_spent
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at >= '2024-01-01'
AND u.status = 'active'
GROUP BY u.id, u.email
ORDER BY total_spent DESC
LIMIT 100;
Step 2: Identify issues from execution plan
Step 3: Create strategic indexes
-- Covering index for users with partial index
CREATE INDEX CONCURRENTLY idx_users_status_created_active
ON users (status, created_at)
INCLUDE (id, email)
WHERE status = 'active';
-- Covering index for orders JOIN
CREATE INDEX CONCURRENTLY idx_orders_user_id_total
ON orders (user_id)
INCLUDE (id, total);
-- Update statistics
ANALYZE users;
ANALYZE orders;
Step 4: Verify optimization
EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
-- Same query - should now show:
-- - Index Only Scan instead of Seq Scan
-- - Heap Fetches: 0
-- - Execution Time: <100ms
Expected outcome:
| Metric | OLTP Target | Analytics Target | |--------|-------------|------------------| | P50 latency | <50ms | <2s | | P95 latency | <100ms | <5s | | P99 latency | <200ms | <10s | | Cache hit ratio | >95% | >90% | | Index usage | >95% | >80% |
| Parameter | Formula | Example (32GB RAM) | |-----------|---------|-------------------| | shared_buffers | 25% of RAM | 8GB | | effective_cache_size | 75% of RAM | 24GB | | work_mem | RAM / max_connections / 4 | 40MB | | maintenance_work_mem | 10% of RAM | 2GB | | random_page_cost | 1.1 (SSD) / 4.0 (HDD) | 1.1 |
| Observation | Action | |-------------|--------| | Query complexity explosion | Escalate to architect for schema redesign | | Replication lag >10s | Escalate to DBA for infrastructure review | | Connection pool exhaustion | Review application connection handling | | Disk I/O saturation | Consider read replicas or caching layer |
Detailed Technical Reference: See REFERENCE.md
Code Examples & Patterns: See EXAMPLES.md
development
Expert in automating Excel workflows using Node.js (ExcelJS, SheetJS) and Python (pandas, openpyxl).
content-media
Expert in designing durable, scalable workflow systems using Temporal, Camunda, and Event-Driven Architectures.
tools
Use when user needs WordPress development, theme or plugin creation, site optimization, security hardening, multisite management, or scaling WordPress from small sites to enterprise platforms.
tools
Expert in Windows Server, Active Directory (AD DS), Hybrid Identity (Entra ID), and PowerShell automation.