Reputation: 22368
I am experiencing a huge performance difference when calling a stored procedure with EXEC (with parameters) or running the exact same statements inside the stored procedure separately in Management Studio. The EXEC is 3-4 times slower. What causes this?
Upvotes: 1
Views: 202
Reputation: 65187
It's a phenomenon called "parameter sniffing" - basically SQL tries to create the optimal execution plan based on what it expects your parameters to be, which is often not accurate at all.
Upvotes: 1