Community Discussion
Login to join the discussion
100% Free
SQL Query Optimizer — Performance Tuning Expert
Created by
Prompt
PROMPT
1186 chars
ChatGPT-4o
You are a database performance expert specializing in SQL optimization. Analyze the following query and database context:
## Database Engine: [MySQL/PostgreSQL/SQLite/SQL Server]
## Table Schema:
[Paste your CREATE TABLE statements or describe your schema]
## The Slow Query:
[Paste your query here]
## Current Performance:
- Execution time: [e.g., 3.2 seconds]
- Rows scanned: [if known]
- Current indexes: [list existing indexes]
## Your Analysis:
1. **Execution Plan Review**: Explain what the database is doing step by step in plain language. Identify full table scans, inefficient joins, and sorting bottlenecks.
2. **Index Recommendations**: Suggest specific indexes with CREATE INDEX statements. Explain which part of the query each index optimizes.
3. **Query Rewrite**: Provide an optimized version of the query. Show multiple approaches if applicable (subquery vs JOIN, EXISTS vs IN) with pros/cons.
4. **Schema Suggestions**: If the schema itself is causing issues, suggest normalization/denormalization changes.
5. **Caching Strategy**: Recommend if and how this query result should be cached.
Provide the expected performance improvement estimate for each suggestion.
How to Use This Prompt
1. Always specify your database engine (MySQL, PostgreSQL, etc.) — optimization strategies differ significantly.
2. Include your CREATE TABLE statements for accurate analysis.
3. If you have EXPLAIN/EXPLAIN ANALYZE output, paste it — this dramatically improves the AI's recommendations.
4. Mention the table sizes (row counts) so the AI can gauge the impact.
5. For complex queries with multiple joins, include sample data if possible.
2. Include your CREATE TABLE statements for accurate analysis.
3. If you have EXPLAIN/EXPLAIN ANALYZE output, paste it — this dramatically improves the AI's recommendations.
4. Mention the table sizes (row counts) so the AI can gauge the impact.
5. For complex queries with multiple joins, include sample data if possible.
Created
Feb 13, 2026
Updated
2 months ago
Language
English
Version
4o
Similar Prompts
View All→
ChatGPT-4o
Market Research
Market Research Analyst — Competitive Intelligence
Conduct thorough market research and competitive analysis. Generates SWOT analys...
ChatGPT-4o
Resume & CV
Resume & Cover Letter Optimizer — ATS-Friendly
Optimize your resume and cover letter to pass Applicant Tracking Systems and imp...
ChatGPT-4o
Workflow Automation
Workflow Automation Designer — No-Code/Low-Code
Design automated workflows for repetitive business processes. Generates step-by-...
ChatGPT-4o
Game Design
Game Design Document — Complete GDD Template
Create a comprehensive Game Design Document for any game concept. Covers core me...
No comments yet. Be the first to share your thoughts!