Parameter Sniffing (or Spoofing) in SQL Server
问题 A while ago I had a query that I ran quite a lot for one of my users. It was still being evolved and tweaked but eventually it stablised and ran quite quickly, so we created a stored procedure from it. So far, so normal. The stored procedure, though, was dog slow. No material difference between the query and the proc, but the speed change was massive. [Background, we're running SQL Server 2005.] A friendly local DBA (who no longer works here) took one look at the stored procedure and said