How Do I Know If My Query Is Good Enough for Production?


When I ask that question, here are some of the things I think about:

How many times am I going to run it? Is it a one-off task, or is it going to run thousands of times per second on the front page of a popular web site? What time of the day/week will it run? Are we under peak loads then, or is it an after-hours thing? Does this server usually do small transactional work, or is it a reporting server? Is my query going to hold locks while it runs?

Then, armed with those things, I measure my