Created
January 26, 2019 10:31
-
-
Save ghotz/07350e2202117b5a02fdad9ad97ffe69 to your computer and use it in GitHub Desktop.
Analyze single plan usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| objtype | |
| , COUNT_BIG(*) AS plans_count | |
| , SUM(CAST(size_in_bytes AS bigint) / 1024. / 1024.) AS plans_MB | |
| , AVG(usecounts) AS plans_count_avg | |
| , SUM(CASE WHEN usecounts = 1 THEN 1 ELSE 0 END) AS plans_single_use_count | |
| , SUM(CASE WHEN usecounts = 1 THEN CAST(size_in_bytes AS bigint) / 1024. / 1024. ELSE 0 END) AS plans_single_use_MB | |
| FROM sys.dm_exec_cached_plans | |
| GROUP BY objtype | |
| ORDER BY plans_single_use_MB DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment