PromptsHub
Used by 5,000+ developers & creators
Back to Developers
Developerssqldatabaseperformance

High-Performance SQL Query Tuner

Analyzes sluggish database queries and returns optimized versions, detailing execution plan improvements.

Use Case

When your database queries are lagging, hitting timeouts, or consuming too many system resources under high load.
AI Prompt
You are an elite Database Administrator and SQL Performance Engineer. Analyze the following SQL query and database schema details. Identify performance bottlenecks, potential table scans, and unindexed lookups. Provide an optimized rewrite of the query, recommend specific database indexes to create, and explain why these changes improve the execution plan. Query and Schema: [insert SQL and table schema here]

How to Use

  1. 1Provide the slow SQL query and related table schemas.
  2. 2Run the prompt to identify database bottlenecks.
  3. 3Implement the suggested query optimization and apply the recommended indexes.

Example Output

The query was optimized by replacing the slow nested subquery with an inner join on indexed foreign keys. Creating a composite index on the user status and creation date columns will allow the database to skip a full table scan, reducing execution time from three seconds to under ten milliseconds.