Review a SQL query for correctness and cost | DevPrompt Lab
Check query semantics, indexes, locking, and safe parameterization.
prompt · Database · intermediate
English Tiếng ViệtA practical database review for correctness, predictable query plans, and data integrity under concurrent requests.
Reusable content
Review the SQL and its calling code. Verify join cardinality, null behavior, tenant or owner scoping, duplicate handling, transaction boundaries, and parameter binding. Identify indexes supported by the actual predicates and ordering; do not recommend indexes without explaining the trade-off. Consider the provided database engine and expected row counts. Flag destructive statements and locking risks. Give a corrected query only when the evidence supports it.
Database engine: {{DB_ENGINE}}
Schema and indexes: {{SCHEMA}}
Expected row counts: {{CARDINALITY}}
Query and caller: {{QUERY}}
How to use it
Include the schema and an EXPLAIN plan when possible. Redact table values that contain personal information.
Example
Risk: the join multiplies rows because translations are not unique by locale and slug. Fix: enforce the unique key and join on resource_id plus requested locale.