If You Could Only Say One Thing About Writing Good Queries…

If you could give just one piece of advice about writing good queries, what would it be?

I asked Twitter yesterday because I wanted to make sure I didn’t miss anything in a new training course I’m working on, and the replies were fantastic. Here were some of my favorites:

As you’re writing a query, give a play by play in the comments explaining what you’re doing and why. A. You will catch more of your mistakes.

— BD Softley (@BigfootSql) May 3, 2021

Understand execution plans, look at actual ones and analyse.

— Stefán Jökull Sigurðarson