Home Tools Prompts SQL Query Optimizer
Coding intermediate

SQL Query Optimizer

Optimizes slow SQL queries, identifies bottlenecks, and suggests indexing strategies.

Works with: all
Prompt
Act as a database performance expert. Optimize the following SQL query for [DATABASE_TYPE]: '[SLOW_QUERY]'. Explain the performance bottlenecks, suggest necessary indexes, and provide the rewritten query.
Example Output
Bottlenecks: The query performs a full table scan due to the unindexed status column and a non-sargable WHERE clause.

Recommended Index: CREATE INDEX idx_orders_status ON orders(status);

Optimized Query:
sql
SELECT order_id, customer_id, total_amount
FROM orders
WHERE status = 'active' AND created_at >= '2026-01-01';
#sql #database #performance #optimization