SQL Query Optimizer
Get a performance audit of your SQL query with bottleneck identification, optimized rewrite, index suggestions, and scalability analysis.
Analyze the following [DATABASE_TYPE, e.g., PostgreSQL, MySQL] query for performance bottlenecks:
[PASTE YOUR SQL QUERY]
The query runs on a table with approximately ⟨TABLE_SIZE⟩ rows. Current execution time: [TIME, if known] EXPLAIN output: [PASTE EXPLAIN OUTPUT IF AVAILABLE]
Please:
- Identify Inefficiencies: Full table scans, missing indexes, cartesian joins, N+1 patterns, unnecessary subqueries
- Rewrite the Query: Provide an optimized version with:
- Suggested indexes (CREATE INDEX statements)
- Query restructuring (CTEs, window functions, JOINs instead of subqueries)
- Pagination strategy if returning large result sets
- Estimate Improvement: Before/after complexity analysis
- Edge Cases: What happens when the table grows 10x? Will the query still perform?
This prompt contains variables shown as ⟨variable_name⟩. Replace them with your own values before using.
How to Use
Paste your SQL query, specify the database type and table size. Include EXPLAIN output if available for the most accurate optimization.
Related Prompts
More prompts in Data & Analytics
Sql Agent System Prompt
LangChain Hub prompt: langchain-ai/sql-agent-system-prompt
Buyer Persona Legend
Generate detailed User Personas for your Business with data neatly organized into a table.
Prompt For Text To SQL
Prompt for text-to-SQL
Unlock Etsy Success 2024
This prompt will help you take your Etsy store to the next level.
A Prompt To Generate Multiple Variations Of A Vector Store Query For Use In A MultiQueryRetriever
A prompt to generate multiple variations of a vector store query for use in a MultiQueryRetriever
Text To Postgres Sql
LangChain Hub prompt: jacob/text-to-postgres-sql