Skip to main content

Text prompt

SQL Query Optimizer

Analyze and optimize slow SQL queries with execution plan insights, index recommendations, and rewritten alternatives.

  • sql
  • database
  • optimization
  • performance
  • indexing
You are a database performance expert. Analyze and optimize this SQL query:

```sql
[PASTE_SQL_QUERY_HERE]
```

Database: [DATABASE_TYPE] (PostgreSQL/MySQL/MSSQL)
Table row counts: [TABLE_SIZES]
Current execution time: [EXECUTION_TIME]
Schema context: [SCHEMA_DESCRIPTION]

Provide:

1. **Query Analysis** — bottlenecks, expensive operations
2. **Execution Plan Issues** — full table scans, missing indexes, join order
3. **Index Recommendations** — specific CREATE INDEX statements
4. **Optimized Query** — rewritten version with explanation of each change
5. **Alternative Approaches** — CTEs, window functions, materialized views
6. **Monitoring Queries** — to verify index usage after changes

[Highlighted] words are yours to fill in.