@@ -2111,19 +2111,19 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
2111
2111
2112
2112
2113
2113
/* Query Problems - Statistics Updated Recently - CheckID 44 */
2114
- CREATE TABLE #UpdatedStats (Details NVARCHAR (4000 ), RowsForSorting BIGINT );
2114
+ CREATE TABLE #UpdatedStats (HowToStopIt NVARCHAR (4000 ), RowsForSorting BIGINT );
2115
2115
IF EXISTS (SELECT * FROM sys .all_objects WHERE name = ' dm_db_stats_properties' )
2116
2116
BEGIN
2117
2117
EXEC sp_MSforeachdb N' USE [?];
2118
- INSERT INTO #UpdatedStats(Details , RowsForSorting)
2119
- SELECT Details =
2118
+ INSERT INTO #UpdatedStats(HowToStopIt , RowsForSorting)
2119
+ SELECT HowToStopIt =
2120
2120
QUOTENAME(DB_NAME()) + N'' .'' +
2121
2121
QUOTENAME(SCHEMA_NAME(obj.schema_id)) + N'' .'' +
2122
2122
QUOTENAME(obj.name) +
2123
2123
N'' statistic '' + QUOTENAME(stat.name) +
2124
2124
N'' was updated on '' + CONVERT(NVARCHAR(50), sp.last_updated, 121) + N'' ,'' +
2125
2125
N'' had '' + CAST(sp.rows AS NVARCHAR(50)) + N'' rows, with '' +
2126
- CAST(sp.rows_sampled AS NVARCHAR(50)) + N'' rows sampled, '' +
2126
+ CAST(sp.rows_sampled AS NVARCHAR(50)) + N'' rows sampled,'' +
2127
2127
N'' producing '' + CAST(sp.steps AS NVARCHAR(50)) + N'' steps in the histogram.'' ,
2128
2128
sp.rows
2129
2129
FROM sys.objects AS obj
@@ -2135,16 +2135,21 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
2135
2135
END ;
2136
2136
2137
2137
IF EXISTS (SELECT * FROM #UpdatedStats)
2138
- INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL , Details)
2138
+ INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL , Details, HowToStopIt )
2139
2139
SELECT 44 AS CheckId,
2140
2140
50 AS Priority,
2141
2141
' Query Problems' AS FindingGroup,
2142
2142
' Statistics Updated Recently' AS Finding,
2143
2143
' http://www.BrentOzar.com/go/stats' AS URL ,
2144
- Details = LEFT ((SELECT (SELECT Details + NCHAR (10 ))
2144
+ ' In the last 15 minutes, statistics were updated. To see which ones, click the HowToStopIt column.' + @LineFeed + @LineFeed
2145
+ + ' This effectively clears the plan cache for queries that involve these tables,' + @LineFeed
2146
+ + ' which thereby causes parameter sniffing: those queries are now getting brand new' + @LineFeed
2147
+ + ' query plans based on whatever parameters happen to call them next.' + @LineFeed + @LineFeed
2148
+ + ' Be on the lookout for sudden parameter sniffing issues after this time range.' ,
2149
+ HowToStopIt = (SELECT (SELECT HowToStopIt + NCHAR (10 ))
2145
2150
FROM #UpdatedStats
2146
2151
ORDER BY RowsForSorting DESC
2147
- FOR XML PATH (' ' )), 4000 ) ;
2152
+ FOR XML PATH (' ' ));
2148
2153
2149
2154
RAISERROR (' Finished running investigatory queries' ,10 ,1 ) WITH NOWAIT ;
2150
2155
0 commit comments