I once had a conversation with a colleague regarding a script she had written for a one-time UPDATE and SELECT. I suggested some changes that I felt would improve the performance noticeably and save the DBA who would be running her code a few minutes of his/her life. To my great surprise (though in retrospect I should not have been), she demurred, and said that performance didn’t matter because it was a “one-off” and therefore not worthy of tuning.
I admit that I see her point. Why invest time and effort on a throw-away script? And I know many that would agree with her. But to me, it’s passing up an opportunity to get better. Every script or object I deploy gets scrutinized, because I never know when I’m going to see something that will lead me down the rabbit hole of discovery, into places I’ve never been, to execution plans I’ve never seen. I still remember the magical moment when I “got” merge joins, and understood the insight they provided into the structure and design of my tables. Making that connection – learning to think like the optimizer does, or at least get close – is my daily goal. I try to learn something every day, and the only way to do that is to question everything I do, and to never be satisfied with “it works”.
I admit that not everyone shares that passion. It’s disappointing sometimes to find that many just want their code “to work”, just want to move on to the next work order or project. I wonder if that is something in their character or if it’s more not knowing how to start critiquing your own work. It’s hard to be ruthless on yourself, but ultimately rewarding, and the satisfaction of knowing that you’ve learned something new – that you’re a little better at the end of the day than you were at the beginning – makes it all worthwhile.