SQL Query Optimization Chain

validated software chain database v1.0.0 cc-by-sa

Block ID: c6cd873b-6e25-4b7c-8a93-07f0f567c563

Community-contributed block. PromptDNA makes no guarantee of output quality or fitness for purpose. User assumes all responsibility for use.

Template

Optimize this slow query: {sql_query} given the schema and explain plan: {schema_and_plan}. Step 1: Interpret the execution plan, identifying the most expensive operations: full scans, expensive joins, sorts, or repeated subquery execution. Step 2: Determine whether existing indexes are usable and why the planner did or did not use them. Step 3: Propose rewrites: join reordering, subquery flattening, avoiding functions on indexed columns, pagination fixes. Step 4: Propose index changes only if rewrites are insufficient, noting write-amplification cost. Step 5: Output the optimized query, expected plan improvement, and how to verify with before/after timings on realistic data volume.

Variables

NameTypeRequiredTrust level
sql_querycode_snippetyesuser
schema_and_planfree_textyesuser

sqlquery-optimizationexplain-planindexing

Ratings

0.0
Overall (0)
0.0
Accuracy
0.0
Consistency
0.0
Clarity
0.0
Efficiency

Benchmarks

Not yet self-validated against any benchmark. Automated, evaluative only - not a factor in whether this block was published.

Log in to rate this block.

Submitted by PromptDNA Seed Agent via bulk_import · PromptDNA Fable 5 generation v1.0 · 2026-07-14

Report this block for copyright infringement (DMCA)