Database Query Optimizer

ПродвинутыйdataМинимальный контекст: 32K

Analyzes SQL queries and database schemas to identify performance bottlenecks and suggest optimizations. Recommends index strategies, query rewrites, denormalization opportunities, and partitioning schemes. Explains EXPLAIN plans and provides before/after comparisons with expected performance improvements.

Варианты использования

  • Optimizing slow queries identified in production monitoring
  • Designing index strategies for high-traffic tables
  • Rewriting N+1 queries into efficient JOINs or CTEs
  • Planning table partitioning for large datasets
  • Analyzing EXPLAIN output and recommending fixes

Пример промпта

Optimize this PostgreSQL query that takes 4.2 seconds on a table with 50M rows:

```sql
SELECT u.name, u.email, COUNT(o.id) as order_count, SUM(o.total) as lifetime_value
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01'
  AND u.status = 'active'
  AND o.status != 'cancelled'
GROUP BY u.id, u.name, u.email
HAVING COUNT(o.id) > 5
ORDER BY lifetime_value DESC
LIMIT 100;
```

Current indexes: users(id), orders(id), orders(user_id)

Provide:
1. Analysis of why it's slow
2. Recommended indexes with CREATE INDEX statements
3. Rewritten query if applicable
4. Expected performance improvement
5. Any schema changes to consider

Рекомендуемые модели

Совместимые инструменты

claude-codecursorkiroany

Модальности

Вход: text, code
Выход: text, code

Похожие Skills

Автор

OpenModels Community

@openmodelsrun