Today, I had an issue with a SPROC Timing Out (took longer than 30 seconds) when it was run from an ASP.NET webpage, but executed quickly when run from SSMS (took 5 seconds).
After suspecting Parameter Sniffing as the culprit, I Masked the Input Parameters, and the query executed faster.
My Question Is:
Why did this happen? This system has been in production for more than 5 years, and this is the first time we've seen anything like this on our SPROCs. Is this "Database wear and tear"?
We've resolved the issue, so it isn't a big deal, but I'm just curious as to why this was happening.
DROP/CREATE PROC.sql files, I typically include anEXECfor the sproc, with realistic parameters. Thus, any time the sproc is recreated, it gets run once with good params and (should) get a good execution plan. – Jon of All Trades Jun 12 '12 at 17:01