Parameters and Presses
Parameters & Presses I was in the gym on Tuesday and had this idea whilst executing some shoulder presses. About how picking a weight is similar to a common issue in stored procedures: Parameter Sniffing. Before I can make the comparison, let's define Parameter Sniffing. Oftentime, stored procedures in SQL are driven by a parameter being passed to define the criteria for a query. These can be incredibly simple to ultra complex. For the purposes of my example today, I have an extremely simple procedure. See below. I've got a procedure called ParamSniff which accepts one parameter called Location. Then I have a very simple SELECT query that uses that parameter in the where clause. When you execute the procedure it passes the required parameter value through and searches for that. Now, if this is the very first time the procedure has been run or the server and/or SQL services have been restarted recently, there is no cached execution plan for this procedure. So the SQL Engin...