Study AI Mastery

Master AI. Shape Your Future. Learn to leverage ChatGPT, Claude AI, and the world's most powerful AI platforms—from complete beginner to expert level.

Platform

  • Start Here
  • New to AI? Start Here
  • For Parents & Educators
  • For Students
  • For Schools
  • Learning Paths
  • Platform Comparison
  • Free Resources
  • Pricing
  • Developer API
  • Alternatives
  • Best AI for…

Company

  • About Us
  • Contact
  • FAQ
  • What's New
  • Privacy Policy
  • Terms of Service
  • Refunds

© 2026 Study AI Mastery. All rights reserved.

Study AI Mastery is operated by Our Rose LLC. Charges appear on your card statement as OUR ROSE LLC.

Database Query Optimizer

Verified

Analyze and optimize slow database queries with explanations.

advanced
universal

The Prompt

✨ Try in Playground
Act as a database performance engineer.

Optimize this slow query:

```sql
[PASTE YOUR SLOW QUERY]
```

Context:
- Database: [PostgreSQL / MySQL / SQLite / MongoDB]
- Table sizes: [APPROXIMATE ROW COUNTS]
- Current execution time: [HOW LONG IT TAKES]
- Existing indexes: [LIST OR "UNKNOWN"]
- How often this query runs: [FREQUENCY]

Provide:
1. **Analysis** — Why is this query slow? (explain the execution plan)
2. **Optimized Query** — Rewritten for performance
3. **Indexes** — Exactly which indexes to create (with CREATE INDEX statements)
4. **Explanation** — Why each change improves performance
5. **Expected improvement** — Rough estimate of speed gain
6. **Trade-offs** — Any downsides to the optimization (write speed, storage)

If the query structure itself is the problem, suggest an alternative approach (materialized view, caching, denormalization).

Use Case

Turn slow queries into fast ones with expert optimization advice.

How to Use

  1. 1Copy the prompt using the button above
  2. 2Replace text in [BRACKETS] with your specific information
  3. 3Paste into any AI platform
  4. 4Review and refine the output as needed

Category

coding

Tags

database
sql
performance
optimization

Access

FREE

Related Prompts

Verified
beginner

Git Commit Message Writer

Write clear, conventional commit messages that tell a story.

Verified
beginner

Error Message Debugger

Diagnose error messages and get step-by-step fix instructions.

Verified
advanced

Technical Architecture Reviewer

Get expert review of your system architecture decisions.

Want to create prompts like this?

Our Prompt Engineering course teaches you the techniques behind every great prompt.

Ratings & Reviews

Please sign in to rate and review this prompt