SQL doesn't get the same formatting discipline as application code. There's no equivalent of Prettier running on every commit, so queries drift toward whatever shape the last person who touched them left it in — inconsistent keyword casing, inconsistent indentation, joins that wrap differently from file to file.
The convention worth adopting first is picking one keyword case for the whole codebase and sticking to it. It doesn't matter much whether it's uppercase `SELECT` or lowercase `select` — what matters is that a reviewer's eye doesn't have to re-parse casing on every query to find the actual logic.
The second is consistent indentation on joins and conditions, so a query with four joins reads as four aligned lines instead of a wall of text. This is the single biggest readability lever for anything beyond a trivial query.
The third, and the one people skip most, is reformatting a query in its own commit when you're about to make a substantive change to it. A diff that mixes formatting and logic changes is much harder to review than two diffs, even though it's more commits.
More from the blog
What We're Building Next: dont-break-prod
A PR-review training game for payments engineers — read the contract, read the code, decide if it's safe to ship.
5 Habits for Debugging Messy JSON Payloads Faster
The difference between a two-minute payload review and a twenty-minute one usually comes down to a few small habits.
Testing Webhooks Locally Without Exposing Your Machine
You don't need to punch a hole in your firewall to see what a provider actually sends before your endpoint touches it.