Learn SQL
-- advanced.pr_review_checklist_sql

Reviewing SQL Pull Requests

Semantics before style — predicates, NULLs, fan-out

--concept

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.

--how it works
1

Correctness gates

Correlation exact? NULL-safe? Fan-out-proof? Destructive previewed with counts?

2

Performance proof

EXPLAIN new shapes; indexes on new paths; N+1 and width checked.

3

Safety bars

Placeholders only; least-privilege role; no secrets; chunked millions.

4

Tests + radius

Fixture assertions updated; blast radius + rollback stated in the PR.

--visualization
pillarorder
correctnessfirst
performancesecond
safetythird
Stage 1 / 1
Destructive writes need SELECT preview + count. Style never outranks semantics.
--example
query.sql
1-- review demands:
2-- SELECT <same WHERE> first (count + sample)
3-- EXPLAIN new JOIN shape
4-- placeholders, never interpolation
Result
pillarchecks
correctnesspredicates/NULLs/fan-out
performanceEXPLAIN/index/N+1
safetyparams/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.

--variants

Three pillars in order

Style never outranks semantics.

query.sql
1-- correctness: predicates/NULLs/fan-out/preview
2-- performance: EXPLAIN/index/N+1
3-- safety: params/privilege/secrets
Result
pillarorder
correctnessfirst
performancesecond
safetythird
1Formatting nits wait.
2Uncorrelated DELETE fails the review alone.
3Missing correlation is the costliest miss.

Destructive-write gate

No preview, no merge.

query.sql
1-- PR must show: SELECT <same WHERE> count+sample + txn plan
Result
gateproof
previewmandatory
txnBEGIN verify COMMIT/ROLLBACK
1Count bounds the blast.
2Sample proves the predicate.
3Chunked + idempotent for millions.
--key facts
Semantics firststyle last
Preview writesSELECT + count mandatory
Costliest missuncorrelated destructive
--use cases
Team SQL review with shared gates
Onboarding: what seniors check first
--under the hood
Review bots can lint interpolation/missing-WHERE/SELECT * — humans judge correlation and fan-out.
Query-log sampling in staging proves N+1 before merge.

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Take the queries you just visualized and see the data structures that power real databases.