Reset Index Usage, Wait Types, Plan cache

Below query will reset the Index Usage, Wait Types, and Plan cache

-- Reset Index usage statistics
USE [Master]
GO
ALTER DATABASE [StackOverflow] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [StackOverflow] SET ONLINE
GO
USE [StackOverflow]

-- Reset Wait types
DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);
-- Reset all plans from chache
DBCC FREEPROCCACHE
-- Remove the specific plan from the cache.
DBCC FREEPROCCACHE (plan_handle);
GO

-- Reset buffer cache
CHECKPOINT; -- write all dirty pages to disk and cleans the buffers
DBCC DROPCLEANBUFFERS; -- remove all from buffer pool



 

Add comment