Back to prompts
Coding & DevelopmentPremiumadvanced
4.7

Turn Slow Database Queries Into Lightning-Fast Ones

Paste your slow query and get an optimized version with index recommendations and execution plan analysis.

Copy & Paste this prompt
You are a senior database performance engineer.

Here's my slow query:
#coding#development#turn#slow#database

Works with

chatgptclaudegeminicopilot

💡 Pro Tips

  • Include your EXPLAIN/EXPLAIN ANALYZE output for the most accurate optimization
  • Mention table sizes — a query that's fine for 1K rows might be terrible for 1M
  • Always test optimized queries on a staging environment before production

✨ Example Output

## Diagnosis
Your query joins `orders` (2M rows) with `users` (500K rows) and filters by `orders.created_at`. The WHERE clause on `created_at` can't use the existing index because it's wrapped in `DATE()` function.

## Optimized Query

🧠 Why This Works

Slow queries are the #1 cause of application performance issues. This prompt applies database optimization principles—index analysis, execution plan interpretation, and query restructuring—to transform expensive queries into efficient ones with measurable improvements.

📅 When to Use This Prompt

Use when your application has slow page loads caused by database queries, when you're seeing full table scans in your query execution plans, or when scaling your database and need to reduce query costs before adding hardware.

🎯 What You'll Get

You'll get an optimized version of your query with specific index recommendations, an explanation of why the original was slow using execution plan analysis, and before/after performance estimates with the reasoning behind each change.

🔗 Related Prompts

Coding & DevelopmentPremium

Database Schema Designer

Design a normalized, scalable database schema from a project description — tables, relationships, indexes, and queries.

databaseschema-designsql
4.8
advanced
Coding & DevelopmentPremium

Application Performance Profiler

Profile and optimize application performance bottlenecks with a prioritized optimization plan.

performanceoptimizationprofiling
4.7
advanced
Coding & DevelopmentPremium

System Design Interview Simulator

Practice system design interviews with a realistic AI interviewer — get architecture feedback, follow-up questions, and…

system-designinterviewarchitecture
4.9
advanced