I've looked all over f开发者_JAVA百科or this command....what's the command to reset the SQL Server's execution plan?
For clarity..........
Executing sp_recompile
will "mark" the given stored procedure for recompilation, which will occur the next time it is executed.
Using the WITH RECOMPILE
option will result in a new execution plan being generated each time the given stored procedure is executed.
To clear the entire procedure cache execute
DBCC FREEPROCCACHE
For stored procedures, you use the WITH RECOMPILE
option.
If you want to reset QEP for a stored procedure, you shall use sp_recompile
It's not entirely clear from your question what you're after. But in addition to the other suggestions, DBCC FREEPROCCACHE clears all cached execution plans.
sp_recompile will dump the existing query plan and recompile the procedure. Or you can restart SQL and that will clear the entire execution plan cache.
WITH RECOMPILE is going to generate a new plan EVERY time you execute it.
精彩评论