Skip to main content
VePrompts
claude-opus-4 Coding & Development

While optimized for claude-opus-4, this prompt is compatible with most major AI models.

Optimize SQL Query

Make your database queries faster with indexing, rewriting, and execution plan analysis.

Share

Prompt Health: 100%

Length
Structure
Variables
Est. 237 tokens
# Optimize SQL Query **Best model:** Claude 4 Opus **Category:** Coding & Development **Tags:** SQL, performance, database optimization, backend ## Description Make your database queries faster with indexing, rewriting, and execution plan analysis. ## Prompt Optimize this SQL query. Current performance: [DESCRIBE - slow, timeouts, high CPU]. Table sizes: [ROW COUNTS]. QUERY: [SQL] Provide: 1. EXECUTION PLAN ANALYSIS: What's likely causing slowness (full table scans, nested loops, missing indexes). 2. OPTIMIZED QUERY: Rewritten SQL with improvements. 3. INDEX RECOMMENDATIONS: Specific CREATE INDEX statements with rationale. 4. SCHEMA CHANGES: Any denormalization or structure changes that would help. 5. ESTIMATED IMPROVEMENT: Expected speedup (e.g., 'should reduce from 5s to 200ms'). 6. ALTERNATIVES: If this is a reporting query, suggest materialized views or caching strategies. Use [DATABASE - PostgreSQL/MySQL/SQL Server].

Private Notes

Insert Into Your AI

Edit the prompt above then feed it directly to your favorite AI model

Clicking opens the AI in a new tab. Content is also copied to clipboard for backup.

Explore Related Resources