• Browse Prompts
  • Trending
  • Saved Prompts
  • Web Dev
  • Marketing
  • Blog
  • Submit Your Prompt
PromptsVault AI LogoPromptsVault AI
  • Browse
  • Trending
  • Blog
  • Saved
  • Submit Your Prompt
PromptsVault AI LogoPromptsVault AI

The world's best AI prompts library. Hand-curated, high-quality prompts for ChatGPT, Claude, and Midjourney. Built for productivity and high-accuracy results.

Categories

  • Web Dev
  • AI/ML
  • Marketing
  • Coding
  • Creative
  • View All →

Popular Topics

  • chatgpt
  • midjourney
  • marketing
  • coding
  • seo
  • writing
  • social media
  • email

Legal

  • About Us
  • AI Blog
  • Privacy
  • Terms
  • Disclaimer

© 2026 PromptsVault AI. All rights reserved.

PromptsVault AI is thinking...

Searching the best prompts from our community

ChatGPTMidjourneyClaude
  1. Home
  2. Library
  3. CODING
  4. SQL Query Optimizer
CODING
Nano
6 views
AI Prompt for

SQL Query Optimizer

💡 USAGE TIPS
Optional - Click to learn how to use this prompt effectively

💡 Pro Developer Tips

Click to view expert tips

Specify framework versions

e.g., 'Next.js 14', 'Python 3.11' for accurate, up-to-date code

Request error handling & types

Ask for TypeScript definitions and try-catch blocks

Get step-by-step breakdowns

Request explanations before code for complex logic

Pro tip: The more context you provide, the better your results!
ACTUAL PROMPT BELOW
PROMPT
Copy & Use FREE

🎭 Role

You are a Senior Database Architect and Performance Tuning Expert with deep expertise in query execution plan analysis, indexing strategies, and database engine internals (e.g., PostgreSQL, MySQL, SQL Server). Your goal is to identify bottlenecks and provide high-impact optimization recommendations that prioritize both query performance and long-term system maintainability.

🌐 Context

I am currently managing a database environment experiencing performance degradation on a specific set of critical queries. The objective is to reduce execution time, minimize I/O overhead, and lower CPU consumption without compromising data integrity.

🛠️ Task Instruction

Please perform a comprehensive analysis of the provided query and schema by following these steps:

  1. Bottleneck Identification: Analyze the query execution flow. Identify specific segments (e.g., nested loops, full table scans, sorting operations, or redundant joins) that contribute to high latency.
  2. Indexing Strategy: Recommend specific indexes (including composite, covering, or functional indexes) that would benefit the query, explaining the logic behind your choice based on column selectivity and join patterns.
  3. Query Refactoring: Provide a rewritten version of the query if the current SQL structure is inefficient (e.g., replacing subqueries with CTEs/JOINs, eliminating redundant operations, or improving filtering logic).
  4. Advanced Optimization: If applicable, suggest schema-level changes such as partitioning, denormalization, or materialized views, only if the performance gains justify the architectural complexity.
  5. Execution Plan Request: Outline which EXPLAIN ANALYZE or execution plan details you would need to confirm your hypotheses if more precision is required.

⚖️ Constraints & Tone

  • Tone: Professional, analytical, and highly technical.
  • Length: Be concise but thorough. Focus on actionable insights.
  • Avoid: Generic advice like "add an index" without explaining the column order or specific impact on the query. Do not offer basic SQL syntax explanations unless relevant to the optimization.

Input Data

  • SQL Query: [PASTE QUERY HERE]
  • Table Schema: [PASTE SCHEMA HERE]
  • Database Engine: [E.G., POSTGRESQL 15 / MYSQL 8.0 / SQL SERVER 2022]

📝 Output Format

  1. Executive Summary: A high-level overview of the primary performance issue.
  2. Analysis Breakdown: Bulleted list of identified bottlenecks.
  3. Recommended Optimizations: Categorized by "Query Refactoring" and "Indexing Strategy."
  4. Rewritten Query: A clean, optimized SQL snippet.
  5. Implementation Risk: A brief assessment of potential impacts or trade-offs for these changes.
Pro Tip: This prompt is engineered to favor SEO-best practices, helping you generate high-ranking, authoritative content that satisfies user intent.
Disclaimer: AI models can hallucinate. Please verify this prompt's output before use. PromptsVault AI is not responsible for AI-generated content.

About This Prompt

What is a good ChatGPT prompt for SQL Query Optimizer?

A proven free prompt for SQL Query Optimizer is: "I have a slow-running SQL query. Here is the query: [paste query here]. And here is the table schema: [paste schema here]. Analyze the query and suggest ways to optimize it. Consider adding indexes, r..." — You can copy it for free on PromptsVault AI and paste it directly into ChatGPT, Claude, or Gemini.

How do I use this CODING AI prompt for SQL Query Optimizer?

Click the 'Copy Prompt' button at the top of the page, then paste the text into ChatGPT, Claude, Gemini, or any AI model. You can customize any variables in [brackets] to fit your specific needs before submitting.

Is the SQL Query Optimizer prompt free to use?

Yes — this CODING AI prompt is 100% free on PromptsVault AI. No sign-up or payment required. You can copy and use it for personal or commercial projects with no attribution needed.

Which AI tools work best with this SQL Query Optimizer prompt?

This prompt works with all major AI tools — ChatGPT (GPT-4o), Claude 3 (Anthropic), Google Gemini, Grok (xAI), Microsoft Copilot, Perplexity, Mistral, and Llama. The prompt is written in plain language so it's compatible with any large language model.

Related Tags

#sql#database#performance#optimization

Advertisement

Join the Community

Submit your prompts and join our elite community of creators!

Submit Now

Related Prompts

C

Scalable URL shortener system design

CODING

C

PostgreSQL query performance tuning guide

CODING

C

Scalable Cypress E2E testing framework

CODING

C

Security best practices OWASP Top 10

CODING