SQL poor stored procedure execution plan performance - parameter sniffing
I have a stored procedure that accepts a date input that is later set to the current date if no value is passed in: CREATE PROCEDURE MyProc @MyDate DATETIME = NULL AS IF @MyDate IS NULL SET @MyDate = CURRENT_TIMESTAMP -- Do Something using @MyDate I'm having problems whereby if @MyDate is passed in as NULL when the stored procedure is first compiled, the performance is always terrible for all input values ( NULL or otherwise), wheras if a date / the current date is passed in when the stored procedure is compiled performance is fine for all input values ( NULL or otherwise). What is also