Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Reset SQL Server execution plan

Writer Matthew Martinez

I've looked all over for this command....what's the command to reset the SQL Server's execution plan?

5 Answers

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
2

For stored procedures, you use the WITH RECOMPILE option.

2

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy