I have a stored procedure that finishes execution after a few ms when I run it by itself. However, once I import the stored procedure into EF and call it with the same exact parameters, it takes like 5 minutes to finish. Is there some kind of setting I need to tweak or what is causing this slowness?
Asked
Active
Viewed 623 times
1 Answers
5
I've seen people have this issue when SQL Server has a bad cached execution plan. People seem to recommend running the following commands to fix it:
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
See Stored procedure slow when called from web, fast from Management Studio for a more complete answer.

Community
- 1
- 1

StriplingWarrior
- 151,543
- 27
- 246
- 315
-
Altough you're not the author of the original answer(s), you have been straight to the point. I had the problem, and after applying these queries my SP has dropped from 2 minutes to a (normal) 5 seconds to execute properly : THANK YOU. – AFract Jun 16 '16 at 10:03