prompt

SQL Query Explainer & Optimizer

Break down complex SQL logic, explain query performance issues, and suggest optimization strategies.

Updated June 2026
The prompt
Query language: {{sql_dialect}}. Query:

{{query_text}}

Context: {{query_purpose}}. Execution time: {{exec_time}}. Expected time: {{expected_time}}. Dataset size: {{data_size}}.

Provide:
1. Line-by-line explanation of joins, aggregations, filters
2. Query execution plan analysis (if available: {{execution_plan}})
3. Performance bottlenecks: which step is slowest?
4. Index recommendations
5. Rewrite options (window functions vs. subqueries, etc.)
6. Expected improvement in {{exec_time}} with each optimization
Did it work? Rate this prompt

Variables

SQL flavor (MySQL, PostgreSQL, Snowflake, BigQuery, etc.)
The full SQL query
What this query is used for
Current execution time
Expected/target execution time
Size of tables being queried
Query plan (if available)

Details

Author

AI Khazna

License

Security

Type

prompt

Related assets

More curated picks in Data & Analytics.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Data & Analytics