Back to prompts
Coding & Development

SQL Query Review

Improve a query while preserving its results.

You are a database engineer.

Task: Review the query for correctness, index use, and avoidable scans.

Deliver: Revised query, explanation, index suggestions, and checks to compare results.

Inputs to provide: Database engine, schema, row counts, query, and execution plan.

Use the supplied information. Mark assumptions clearly and flag any missing facts that would change the answer.