Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d73e1ca

Browse files
Adds count of plans to the percentages line
1 parent 6a3f342 commit d73e1ca

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎sp_BlitzCache.sql‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ CREATE TABLE #plan_creation
11341134
percent_24 DECIMAL(5, 2),
11351135
percent_4 DECIMAL(5, 2),
11361136
percent_1 DECIMAL(5, 2),
1137+
total_plans INT,
11371138
SPID INT
11381139
);
11391140

@@ -1186,10 +1187,11 @@ SELECT SUM(CASE WHEN DATEDIFF(HOUR, deqs.creation_time, SYSDATETIME()) <= 24 THE
11861187
COUNT(deqs.creation_time) AS [total_plans]
11871188
FROM sys.dm_exec_query_stats AS deqs
11881189
)
1189-
INSERT INTO #plan_creation
1190+
INSERT INTO #plan_creation ( percent_24, percent_4, percent_1, total_plans, SPID )
11901191
SELECT CONVERT(DECIMAL(3,2), NULLIF(x.plans_24, 0) / (1. * NULLIF(x.total_plans, 0))) * 100 AS [percent_24],
11911192
CONVERT(DECIMAL(3,2), NULLIF(x.plans_4 , 0) / (1. * NULLIF(x.total_plans, 0))) * 100 AS [percent_4],
11921193
CONVERT(DECIMAL(3,2), NULLIF(x.plans_1 , 0) / (1. * NULLIF(x.total_plans, 0))) * 100 AS [percent_1],
1194+
x.total_plans,
11931195
@@SPID AS SPID
11941196
FROM x
11951197
OPTION (RECOMPILE) ;
@@ -4775,7 +4777,14 @@ BEGIN
47754777
999,
47764778
254,
47774779
'Plan Cache Information',
4778-
'You have ' + CONVERT(NVARCHAR(10), ISNULL(p.percent_24, 0)) + '% plans created in the past 24 hours, ' + CONVERT(NVARCHAR(10), ISNULL(p.percent_4, 0)) + '% created in the past 4 hours, and ' + CONVERT(NVARCHAR(10), ISNULL(p.percent_1, 0)) + '% created in the past 1 hour.',
4780+
'You have ' + CONVERT(NVARCHAR(10), ISNULL(p.total_plans, 0))
4781+
+ ' total plans in your cache, with '
4782+
+ CONVERT(NVARCHAR(10), ISNULL(p.percent_24, 0))
4783+
+ '% plans created in the past 24 hours, '
4784+
+ CONVERT(NVARCHAR(10), ISNULL(p.percent_4, 0))
4785+
+ '% created in the past 4 hours, and '
4786+
+ CONVERT(NVARCHAR(10), ISNULL(p.percent_1, 0))
4787+
+ '% created in the past 1 hour.',
47794788
'',
47804789
'If these percentages are high, it may be a sign of memory pressure or plan cache instability.'
47814790
FROM #plan_creation p ;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /