Skip to content

Instantly share code, notes, and snippets.

@kspearrin
Created March 1, 2018 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kspearrin/9db6900ef9483fcf58c88b92410758ba to your computer and use it in GitHub Desktop.
Save kspearrin/9db6900ef9483fcf58c88b92410758ba to your computer and use it in GitHub Desktop.
Clear Azure SQL Procedure Cache
-- ref: https://dba.stackexchange.com/a/159886
-- run this script against a user database, not master
-- count number of plans currently in cache
select count(*) from sys.dm_exec_cached_plans;
-- Executing this statement will clear the procedure cache in the current database, which means that all queries will have to recompile.
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
-- count number of plans in cache now, after they were cleared from cache
select count(*) from sys.dm_exec_cached_plans;
-- list available plans
select * from sys.dm_exec_cached_plans;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment