SQL Query Optimizer

Get a performance audit of your SQL query with bottleneck identification, optimized rewrite, index suggestions, and scalability analysis.

L
lexiconlabs
·Apr 30, 2026·
267 423 3,100
$4.99
Prompt
109 words

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:

  1. Identify Inefficiencies: Full table scans, missing indexes, cartesian joins, N+1 patterns, unnecessary subqueries
  2. 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
  3. Estimate Improvement: Before/after complexity analysis
  4. 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.

Need help?

Connect with verified experts who can help you succeed.

Related Prompts

More prompts in Data & Analytics

View All