Reviewing SQL Pull Requests
Semantics before style — predicates, NULLs, fan-out
Correctness first (WHERE correlation, NULL handling, fan-out before aggregates, destructive-WHERE preview), then performance (EXPLAIN on new shapes, index coverage, N+1 risk), then safety (parameters not interpolation, least-privilege fit). A review debating formatting while missing an uncorrelated DELETE has failed. Require SELECT-preview + row-count for writes.
Correctness gates
Correlation exact? NULL-safe? Fan-out-proof? Destructive previewed with counts?
Performance proof
EXPLAIN new shapes; indexes on new paths; N+1 and width checked.
Safety bars
Placeholders only; least-privilege role; no secrets; chunked millions.
Tests + radius
Fixture assertions updated; blast radius + rollback stated in the PR.
1-- review demands:2-- SELECT <same WHERE> first (count + sample)3-- EXPLAIN new JOIN shape4-- placeholders, never interpolation
| pillar | checks |
|---|---|
| correctness | predicates/NULLs/fan-out |
| performance | EXPLAIN/index/N+1 |
| safety | params/privilege |
Three pillars in order — a formatting nit never outranks a missing correlation. Uncorrelated UPDATE/DELETE is the most expensive miss; WHERE-on-nullable-side-after-LEFT is second.
Three pillars in order
Style never outranks semantics.
1-- correctness: predicates/NULLs/fan-out/preview2-- performance: EXPLAIN/index/N+13-- safety: params/privilege/secrets
| pillar | order |
|---|---|
| correctness | first |
| performance | second |
| safety | third |
Destructive-write gate
No preview, no merge.
1-- PR must show: SELECT <same WHERE> count+sample + txn plan
| gate | proof |
|---|---|
| preview | mandatory |
| txn | BEGIN verify COMMIT/ROLLBACK |
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Take the queries you just visualized and see the data structures that power real databases.