Install any skill in seconds. Free to start, no credit card required.
Get Started Free →SQL query optimization and database performance specialist. Use when optimizing slow queries, fixing N+1 problems, designing indexes, implementing caching, or improving database performance. Works with PostgreSQL, MySQL, and other databases.
.claude/skills/aiskillstore-database-optimization/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-22 | ✗→✓ | ▲ Improved | 26% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 91% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 26% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 87% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 106% | 0% |
This skill optimizes database performance including query optimization, indexing strategies, N+1 problem resolution, and caching implementation.
Optimize this slow database queryFix the N+1 query problem in this codeAnalyze query performance and suggest indexesTechniques:
Strategies:
Pattern:
python# Bad: N+1 queries users = User.all() for user in users: posts = Post.where(user_id=user.id) # N queries # Good: Single query with JOIN users = User.all().includes(:posts) # 1 query
Input: Optimize slow user query
Output:
markdown## Database Optimization: User Query ### Current Query
SELECT FROM users WHERE email = 'user@example.com'; -- Execution time: 450ms
### Analysis
- Full table scan (no index on email)
- Scanning 1M+ rows
### Optimization
-- Add index CREATE INDEX idx_users_email ON users(email);
-- Optimized query SELECT id, email, name FROM users WHERE email = 'user@example.com'; -- Execution time: 2ms
### Impact
- Query time: 450ms → 2ms (99.5% improvement)
- Index size: ~50MB
references/query_patterns.md - Common query optimization patterns, anti-patterns, and caching strategies| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 5,347 | 5,572 | +4% | 1 | 1 | 0% | 795 | 1,517 | +91% | 0 | 0 | — |
case-02 | pass→pass | 9,689 | 7,943 | -18% | 1 | 1 | 0% | 1,578 | 1,996 | +26% | 0 | 0 | — |
case-03 | pass→pass | 5,529 | 6,404 | +16% | 1 | 1 | 0% | 940 | 1,761 | +87% | 0 | 0 | — |
case-04 | pass→pass | 4,914 | 6,286 | +28% | 1 | 1 | 0% | 861 | 1,771 | +106% | 0 | 0 | — |
case-05 | pass→pass | 10,177 | 12,205 | +20% | 1 | 1 | 0% | 1,545 | 2,634 | +70% | 0 | 0 | — |
case-06 | pass→pass | 6,813 | 5,884 | -14% | 1 | 1 | 0% | 1,204 | 1,784 | +48% | 0 | 0 | — |
case-07 | pass→pass | 9,648 | 7,621 | -21% | 1 | 1 | 0% | 1,653 | 2,000 | +21% | 0 | 0 | — |
case-16 | pass→pass | 9,530 | 9,307 | -2% | 1 | 1 | 0% | 1,507 | 2,209 | +47% | 0 | 0 | — |
case-08 | pass→pass | 10,033 | 10,336 | +3% | 1 | 1 | 0% | 1,537 | 2,317 | +51% | 0 | 0 | — |
case-09 | pass→pass | 6,981 | 7,894 | +13% | 1 | 1 | 0% | 1,060 | 1,930 | +82% | 0 | 0 | — |
case-10 | pass→pass | 3,677 | 4,097 | +11% | 1 | 1 | 0% | 598 | 1,313 | +120% | 0 | 0 | — |
case-11 | pass→pass | 8,636 | 8,169 | -5% | 1 | 1 | 0% | 1,566 | 1,993 | +27% | 0 | 0 | — |
case-12 | pass→pass | 14,776 | 13,504 | -9% | 1 | 1 | 0% | 2,212 | 2,975 | +34% | 0 | 0 | — |
case-13 | pass→pass | 10,774 | 11,004 | +2% | 1 | 1 | 0% | 1,712 | 2,442 | +43% | 0 | 0 | — |
case-14 | pass→pass | 14,203 | 14,973 | +5% | 1 | 1 | 0% | 2,429 | 3,143 | +29% | 0 | 0 | — |
case-15 | pass→pass | 9,901 | 9,336 | -6% | 1 | 1 | 0% | 1,651 | 2,354 | +43% | 0 | 0 | — |
case-17 | pass→pass | 2,933 | 3,659 | +25% | 1 | 1 | 0% | 430 | 1,214 | +182% | 0 | 0 | — |
case-18 | pass→pass | 3,956 | 6,060 | +53% | 1 | 1 | 0% | 600 | 1,733 | +189% | 0 | 0 | — |
case-19 | pass→pass | 3,872 | 4,418 | +14% | 1 | 1 | 0% | 636 | 1,456 | +129% | 0 | 0 | — |
case-20 | pass→pass | 13,910 | 15,094 | +9% | 1 | 1 | 0% | 2,337 | 3,425 | +47% | 0 | 0 | — |
case-21 | pass→pass | 19,548 | 20,128 | +3% | 1 | 1 | 0% | 3,361 | 3,996 | +19% | 0 | 0 | — |
case-22 | fail→pass | 18,243 | 17,950 | -2% | 1 | 1 | 0% | 2,982 | 3,756 | +26% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.