Skip to content

Commit bf9fa8c

Browse files
authored
2019-08 Release (#2094)
* #2005 sp_Blitz version numbers (#2006) Working on #2005. * #2005 easier merges for versions Putting Version, VersionDate variables on a single line. Closes #2005. * #2010 sp_Blitz paused online index operations (#2011) Add warning for rows in sys.index_resumable_operations. Closes #2010. * Fix collation error. (#2014) * #2015 sp_BlitzCache sorting in Azure SQL DB (#2016) Instead of checking version numbers, look at sys.all_columns for the grant and spill columns. Closes #2015. * #2024 sp_BlitzQueryStore s.is_cursor error (#2025) Changed alias on a temp table to match other nearby aliases. Closes #2024. * First responder consistency check (#1997) * sp_Blitz update compile and runs on MSSQL 2014 * Update sp_Blitz.sql Added @debug handling - bug found for missing mandatory component * Update sp_Blitz.sql * Update sp_Blitz.sql CheckId familly: 226 - FRK consistency Messages: 2260 - First Responder kit consistency check has been unexpectedly modified (check names) 2261 - First Responder kit consistency check has been unexpectedly modified (dynamic query failure) 2262 - First Responder kit mandatory component called %s is missing 2263 - First Responder kit consistency check has been unexpectedly modified (checks ordering) 2264 - Component %s is not at the minimum version required to run this procedure 2265 - First Responder kit consistency check (Failed dynamic SP call to %s) 2266 - First Responder kit consistency: outdated component (%s) removed "everything ok message" * Resolves almost all Brent's comments except CHAR(92) change removed 2264 - Component %s is not at the minimum version required to run this procedure changed detailled finding message for previous 2264 message Checked compilation on SQL Server 2014 * #1994 sp_Blitz version checking (#2028) Changed wording from "consistency check" to "version check," updated check IDs, removed mandatory scripts. Closes #1994. * #1944 sp_BlitzIndex ignore databases (#2029) Adds new IgnoreDatabases parameter, and skips databases with >100 partitions. Closes #1944. * #2009 sp_BlitzFirst call BC differently (#2030) Use SkipAnalysis = 1, SortOrder = all when calling sp_BlitzCache. Closes #2009. * #2026 sp_BlitzCache show multiple plan count (#2031) Closes #2026. * #2017 sp_Blitz Evaluation Edition expiration check (#2032) Closes #2017. * #2018 sp_BlitzCache arith overflow (#2033) Changing MONEY on totals to BIGINT. Closes #2018. * #2019 sp_BlitzCache air_quote_actual plans (#2034) Closes #2019. * Add END in the right spot for IF @Help = 1 (#2035) The END for IF @Help = 1 was in the wrong place, making the procedure a no-op *unless* you also specify @Help = 1. * #2037 sp_BlitzLock support for AWS RDS (#2038) Skips update stats with options that RDS doesn't support. Closes #2037. * 2019_04_release_prep Bumping version numbers, building installation scripts. * Moved SQL header build outside of If block (#2040) * #2042 implicit transaction troubleshooting (#2043) Clarify warnings in sp_Blitz, sp_BlitzFirst. Closes #2042. * edit hyperlink (#2056) * add @OutputType = 'XML' (#2048) * Update sp_blitzcache to avoid arithmetic overflow errors (#2046) Updated sp_blitzcache to avoid arithmetic overflow errors - tabel definitions had changed to BIGINT but the actual logic in this section still casted values as money which was breaking the ceiling for this on our setup. I've pretty much blanket chantged everything except averages to be bigint and have been running for a few days with no failrues since so looks ok and worth someone who knows what they're doing casting an eye over it! * Update sp_ineachdb.sql (#2061) Added 2 Variables @SQLVersion: This was implemented so that large organizations with SQL Server 2008 and R2 can use this sproc. Currently without this change SQL Server versions 2008 and 2008R2 will error with the following. Msg 208, Level 16, State 1, Procedure sp_ineachdb, Line 176 Invalid object name 'sys.dm_hadr_database_replica_states'. @ServerName: This was added to account for VMware SnapShots at times @@ServerName will either come up NULL or with old server name. CONVERT(sysname, SERVERPROPERTY('ServerName')) is a better option and reduces minor nuisances. Feel free to blend in the code if you feel this brings value to the project. * ignore readable secondaries in sp_blitzcache (#2049) * ignore readable secondaries in sp_blitzcache this is a fix for issue #2027 * Checking for is_primary_replica column In sys.dm_hadr_database_replica_states. * 2019_07 Release Bumping version numbers and updating install scripts. * Set DBOwner after restoring database (#2082) * Default @RestoreDiff = NULL If @RestoreDiff IS NULL and @BackupPathDiff != null: treat RestoreDiff=1 * Set database owner after restore * Revert restorediff change from dev branch * Exclude Readable secondary DBs (#2073) Temp table added (#ReadableDBs) this table is populated with all read intent database id's which is used to filter out these database when querying against dm_exec_requests or sessions with a cross apply against a plan cache function. * #2067 Updating directory "/" fixing to work with URLs (#2071) * Updating directory "/" fixing to work with URLs Also correcting incorrect logging message for fixing @MoveLogDrive slashes * Fixing variable typo Data should be log * #2076 sp_BlitzIndex columnstore to table (#2085) When saving columnstore definitions to table, trim them to 4000 characters to avoid an overflow. Closes #2076. * @2060 sp_BlitzFirst 2TB RAM (#2086) Casting RAM as a BIGINT instead of INT. Closes #2060. * #2053 sp_BlitzIndex ignoring databases (#2087) Strip out CR/LF from @IgnoreDatabases, trim spaces afterwards. Closes #2053. * #2022 sp_BlitzCache disabling air_quote_actuals (#2088) This SQL 2019 & Azure SQL DB feature isn't ready yet, so disabling til Microsoft is ready. Closes #2022. * #2044 sp_Blitz new power mode (#2089) Adds Windows 10's new Ultimate Performance Power Mode, whatever that is. Closes #2044. * #2062 sp_BlitzFirst false alarm on index reorgs (#2091) Filtering for sql_text not like %alter index%'. Closes #2062 with duct tape. * #2052 sp_BlitzCache prioritization (#2092) Fixes bug in AirQuoteActual plans, plus if plan cache is 75% new as of today, raise priority 1 warning. Closes #2052. * #2070 sp_BlitzCache duplicated index count (#2093) Filters index recommendations by spid. Closes #2070. * sp_DatabaseRestore case bug Inconsistent case sensitivity. * 2019-09 release prep Bumping version numbers and dates.
1 parent f4ed3f0 commit bf9fa8c

15 files changed

+149
-43
lines changed

SqlServerVersions.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DELETE dbo.SqlServerVersions;
3030
INSERT INTO dbo.SqlServerVersions
3131
(MajorVersionNumber, MinorVersionNumber, Branch, [Url], ReleaseDate, MainstreamSupportEndDate, ExtendedSupportEndDate, MajorVersionName, MinorVersionName)
3232
VALUES
33+
(14, 3223, 'RTM CU16', 'https://support.microsoft.com/en-us/help/4508218', '2019-08-01', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 16'),
3334
(14, 3162, 'RTM CU15', 'https://support.microsoft.com/en-us/help/4498951', '2019-05-24', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 15'),
3435
(14, 3076, 'RTM CU14', 'https://support.microsoft.com/en-us/help/4484710', '2019-03-25', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 14'),
3536
(14, 3048, 'RTM CU13', 'https://support.microsoft.com/en-us/help/4466404', '2018-12-18', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 13'),
@@ -46,6 +47,7 @@ VALUES
4647
(14, 3008, 'RTM CU2', 'https://support.microsoft.com/en-us/help/4052574', '2017-11-28', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 2'),
4748
(14, 3006, 'RTM CU1', 'https://support.microsoft.com/en-us/help/4038634', '2017-10-24', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 1'),
4849
(14, 1000, 'RTM ', '', '2017-10-02', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM '),
50+
(13, 5426, 'SP2 CU8', 'https://support.microsoft.com/en-us/help/4505830', '2019-07-31', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 8'),
4951
(13, 5337, 'SP2 CU7', 'https://support.microsoft.com/en-us/help/4495256', '2019-05-23', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 7'),
5052
(13, 5292, 'SP2 CU6', 'https://support.microsoft.com/en-us/help/4488536', '2019-03-19', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 6'),
5153
(13, 5264, 'SP2 CU5', 'https://support.microsoft.com/en-us/help/4475776', '2019-01-23', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 5'),
@@ -82,10 +84,12 @@ VALUES
8284
(13, 2164, 'RTM CU2', 'https://support.microsoft.com/en-us/help/3182270 ', '2016-09-22', '2018-01-09', '2018-01-09', 'SQL Server 2016', 'RTM Cumulative Update 2'),
8385
(13, 2149, 'RTM CU1', 'https://support.microsoft.com/en-us/help/3164674 ', '2016-07-25', '2018-01-09', '2018-01-09', 'SQL Server 2016', 'RTM Cumulative Update 1'),
8486
(13, 1601, 'RTM ', '', '2016-06-01', '2019-01-09', '2019-01-09', 'SQL Server 2016', 'RTM '),
87+
(12, 6329, 'SP3 CU4', 'https://support.microsoft.com/en-us/help/4500181', '2019-07-29', '2019-07-09', '2024-07-09', 'SQL Server 2014', 'Service Pack 3 Cumulative Update 4'),
8588
(12, 6259, 'SP3 CU3', 'https://support.microsoft.com/en-us/help/4491539', '2019-04-16', '2019-07-09', '2024-07-09', 'SQL Server 2014', 'Service Pack 3 Cumulative Update 3'),
8689
(12, 6214, 'SP3 CU2', 'https://support.microsoft.com/en-us/help/4482960', '2019-02-19', '2019-07-09', '2024-07-09', 'SQL Server 2014', 'Service Pack 3 Cumulative Update 2'),
8790
(12, 6205, 'SP3 CU1', 'https://support.microsoft.com/en-us/help/4470220', '2018-12-12', '2019-07-09', '2024-07-09', 'SQL Server 2014', 'Service Pack 3 Cumulative Update 1'),
8891
(12, 6024, 'SP3 ', 'https://support.microsoft.com/en-us/help/4022619', '2018-10-30', '2019-07-09', '2024-07-09', 'SQL Server 2014', 'Service Pack 3 '),
92+
(12, 5687, 'SP2 CU18', 'https://support.microsoft.com/en-us/help/4500180', '2019-07-29', '2020-01-14', '2020-01-14', 'SQL Server 2014', 'Service Pack 2 Cumulative Update 18'),
8993
(12, 5632, 'SP2 CU17', 'https://support.microsoft.com/en-us/help/4491540', '2019-04-16', '2020-01-14', '2020-01-14', 'SQL Server 2014', 'Service Pack 2 Cumulative Update 17'),
9094
(12, 5626, 'SP2 CU16', 'https://support.microsoft.com/en-us/help/4482967', '2019-02-19', '2020-01-14', '2020-01-14', 'SQL Server 2014', 'Service Pack 2 Cumulative Update 16'),
9195
(12, 5605, 'SP2 CU15', 'https://support.microsoft.com/en-us/help/4469137', '2018-12-12', '2020-01-14', '2020-01-14', 'SQL Server 2014', 'Service Pack 2 Cumulative Update 15'),

sp_AllNightLog.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SET NOCOUNT ON;
3030
BEGIN;
3131

3232

33-
SELECT @Version = '3.6', @VersionDate = '20190702';
33+
SELECT @Version = '3.7', @VersionDate = '20190826';
3434

3535
IF(@VersionCheckMode = 1)
3636
BEGIN

sp_AllNightLog_Setup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SET NOCOUNT ON;
3636

3737
BEGIN;
3838

39-
SELECT @Version = '3.6', @VersionDate = '20190702';
39+
SELECT @Version = '3.7', @VersionDate = '20190826';
4040

4141
IF(@VersionCheckMode = 1)
4242
BEGIN

sp_Blitz.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AS
3636
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
3737

3838

39-
SELECT @Version = '7.6', @VersionDate = '20190702';
39+
SELECT @Version = '7.7', @VersionDate = '20190826';
4040
SET @OutputType = UPPER(@OutputType);
4141

4242
IF(@VersionCheckMode = 1)
@@ -8273,6 +8273,8 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
82738273
THEN 'balanced power mode -- Uh... you want your CPUs to run at full speed, right?'
82748274
WHEN '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'
82758275
THEN 'high performance power mode'
8276+
WHEN 'e9a42b02-d5df-448d-aa00-03f14749eb61'
8277+
THEN 'ultimate performance power mode'
82768278
ELSE 'an unknown power mode.'
82778279
END AS Details
82788280

sp_BlitzBackups.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AS
2323
SET NOCOUNT ON;
2424
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2525

26-
SELECT @Version = '3.6', @VersionDate = '20190702';
26+
SELECT @Version = '3.7', @VersionDate = '20190826';
2727

2828
IF(@VersionCheckMode = 1)
2929
BEGIN

sp_BlitzCache.sql

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ BEGIN
271271
SET NOCOUNT ON;
272272
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
273273

274-
SELECT @Version = '7.6', @VersionDate = '20190702';
274+
SELECT @Version = '7.7', @VersionDate = '20190826';
275275

276276

277277
IF(@VersionCheckMode = 1)
@@ -790,6 +790,7 @@ IF @MinutesBack IS NOT NULL
790790

791791
RAISERROR(N'Creating temp tables for results and warnings.', 0, 1) WITH NOWAIT;
792792

793+
793794
IF OBJECT_ID('tempdb.dbo.##BlitzCacheResults') IS NULL
794795
BEGIN
795796
CREATE TABLE ##BlitzCacheResults (
@@ -990,7 +991,9 @@ END;
990991
DECLARE @DurationFilter_i INT,
991992
@MinMemoryPerQuery INT,
992993
@msg NVARCHAR(4000),
993-
@NoobSaibot BIT = 0;
994+
@NoobSaibot BIT = 0,
995+
@VersionShowsAirQuoteActualPlans BIT;
996+
994997

995998
IF @SortOrder = 'sp_BlitzIndex'
996999
BEGIN
@@ -1089,10 +1092,12 @@ IF EXISTS(SELECT * FROM sys.all_columns WHERE OBJECT_ID = OBJECT_ID('sys.dm_exec
10891092
ELSE
10901093
SET @VersionShowsSpills = 0;
10911094

1092-
DECLARE @VersionShowsAirQuoteActualPlans BIT;
1095+
/* This new 2019 & Azure SQL DB feature isn't working consistently, so turning it back off til Microsoft gets it ready.
1096+
See this Github issue for more details: https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2022
10931097
IF EXISTS(SELECT * FROM sys.all_columns WHERE OBJECT_ID = OBJECT_ID('sys.dm_exec_query_plan_stats') AND name = 'query_plan')
10941098
SET @VersionShowsAirQuoteActualPlans = 1;
10951099
ELSE
1100+
*/
10961101
SET @VersionShowsAirQuoteActualPlans = 0;
10971102

10981103
IF @Reanalyze = 1 AND OBJECT_ID('tempdb..##BlitzCacheResults') IS NULL
@@ -1195,6 +1200,9 @@ IF OBJECT_ID('tempdb..#missing_index_pretty') IS NOT NULL
11951200

11961201
IF OBJECT_ID('tempdb..#index_spool_ugly') IS NOT NULL
11971202
DROP TABLE #index_spool_ugly;
1203+
1204+
IF OBJECT_ID('tempdb..#ReadableDBs') IS NOT NULL
1205+
DROP TABLE #ReadableDBs;
11981206

11991207
CREATE TABLE #only_query_hashes (
12001208
query_hash BINARY(8)
@@ -1473,6 +1481,18 @@ CREATE TABLE #index_spool_ugly
14731481
);
14741482

14751483

1484+
CREATE TABLE #ReadableDBs
1485+
(
1486+
database_id INT
1487+
);
1488+
1489+
IF EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
1490+
BEGIN
1491+
RAISERROR('Checking for Read intent databases to exclude',0,0) WITH NOWAIT;
1492+
1493+
EXEC('INSERT INTO #ReadableDBs (database_id) SELECT DBs.database_id FROM sys.databases DBs INNER JOIN sys.availability_replicas Replicas ON DBs.replica_id = Replicas.replica_id WHERE replica_server_name NOT IN (SELECT DISTINCT primary_replica FROM sys.dm_hadr_availability_group_states States) AND Replicas.secondary_role_allow_connections_desc = ''READ_ONLY'' AND replica_server_name = @@SERVERNAME;');
1494+
END
1495+
14761496
RAISERROR(N'Checking plan cache age', 0, 1) WITH NOWAIT;
14771497
WITH x AS (
14781498
SELECT SUM(CASE WHEN DATEDIFF(HOUR, deqs.creation_time, SYSDATETIME()) <= 24 THEN 1 ELSE 0 END) AS [plans_24],
@@ -1802,10 +1822,10 @@ IF @VersionShowsAirQuoteActualPlans = 1
18021822

18031823
SET @body += N' WHERE 1 = 1 ' + @nl ;
18041824

1805-
IF EXISTS (SELECT * FROM sys.all_objects o INNER JOIN sys.all_columns c ON o.object_id = c.object_id WHERE o.name = 'dm_hadr_database_replica_states' AND c.name = 'is_primary_replica')
1825+
IF EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
18061826
BEGIN
18071827
RAISERROR(N'Ignoring readable secondaries databases by default', 0, 1) WITH NOWAIT;
1808-
SET @body += N' AND CAST(xpa.value AS INT) NOT IN (select database_id from sys.dm_hadr_database_replica_states where is_primary_replica = 0 AND DATABASEPROPERTYEX(DB_NAME(database_id), ''Updateability'') = ''READ_ONLY'')' + @nl ;
1828+
SET @body += N' AND CAST(xpa.value AS INT) NOT IN (SELECT database_id FROM #ReadableDBs)' + @nl ;
18091829
END
18101830

18111831
IF @IgnoreSystemDBs = 1
@@ -4438,8 +4458,8 @@ SELECT DISTINCT
44384458
CASE WHEN is_forced_plan = 1 THEN ', Forced Plan' ELSE '' END +
44394459
CASE WHEN is_forced_parameterized = 1 THEN ', Forced Parameterization' ELSE '' END +
44404460
--CASE WHEN unparameterized_query = 1 THEN ', Unparameterized Query' ELSE '' END +
4441-
CASE WHEN missing_index_count > 0 THEN ', Missing Indexes (' + CONVERT(VARCHAR(10), (SELECT SUM(b2.missing_index_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL) ) + ')' ELSE '' END +
4442-
CASE WHEN unmatched_index_count > 0 THEN ', Unmatched Indexes (' + CONVERT(VARCHAR(10), (SELECT SUM(b2.unmatched_index_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL) ) + ')' ELSE '' END +
4461+
CASE WHEN missing_index_count > 0 THEN ', Missing Indexes (' + CONVERT(VARCHAR(10), (SELECT SUM(b2.missing_index_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL AND SPID = @@SPID) ) + ')' ELSE '' END +
4462+
CASE WHEN unmatched_index_count > 0 THEN ', Unmatched Indexes (' + CONVERT(VARCHAR(10), (SELECT SUM(b2.unmatched_index_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL AND SPID = @@SPID) ) + ')' ELSE '' END +
44434463
CASE WHEN is_cursor = 1 THEN ', Cursor'
44444464
+ CASE WHEN is_optimistic_cursor = 1 THEN '; optimistic' ELSE '' END
44454465
+ CASE WHEN is_forward_only_cursor = 0 THEN '; not forward only' ELSE '' END
@@ -4462,8 +4482,8 @@ SELECT DISTINCT
44624482
CASE WHEN is_remote_query_expensive = 1 THEN ', Expensive Remote Query' ELSE '' END +
44634483
CASE WHEN trace_flags_session IS NOT NULL THEN ', Session Level Trace Flag(s) Enabled: ' + trace_flags_session ELSE '' END +
44644484
CASE WHEN is_unused_grant = 1 THEN ', Unused Memory Grant' ELSE '' END +
4465-
CASE WHEN function_count > 0 THEN ', Calls ' + CONVERT(VARCHAR(10), (SELECT SUM(b2.function_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL) ) + ' function(s)' ELSE '' END +
4466-
CASE WHEN clr_function_count > 0 THEN ', Calls ' + CONVERT(VARCHAR(10), (SELECT SUM(b2.clr_function_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL) ) + ' CLR function(s)' ELSE '' END +
4485+
CASE WHEN function_count > 0 THEN ', Calls ' + CONVERT(VARCHAR(10), (SELECT SUM(b2.function_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL AND SPID = @@SPID) ) + ' function(s)' ELSE '' END +
4486+
CASE WHEN clr_function_count > 0 THEN ', Calls ' + CONVERT(VARCHAR(10), (SELECT SUM(b2.clr_function_count) FROM ##BlitzCacheProcs AS b2 WHERE b2.SqlHandle = b.SqlHandle AND b2.QueryHash IS NOT NULL AND SPID = @@SPID) ) + ' CLR function(s)' ELSE '' END +
44674487
CASE WHEN PlanCreationTimeHours <= 4 THEN ', Plan created last 4hrs' ELSE '' END +
44684488
CASE WHEN is_table_variable = 1 THEN ', Table Variables' ELSE '' END +
44694489
CASE WHEN no_stats_warning = 1 THEN ', Columns With No Statistics' ELSE '' END +
@@ -5777,7 +5797,7 @@ BEGIN
57775797
INSERT INTO ##BlitzCacheResults (SPID, CheckID, Priority, FindingsGroup, Finding, URL, Details)
57785798
SELECT SPID,
57795799
999,
5780-
254,
5800+
CASE WHEN ISNULL(p.percent_24, 0) > 75 THEN 1 ELSE 254 END AS Priority,
57815801
'Plan Cache Information',
57825802
'You have ' + CONVERT(NVARCHAR(10), ISNULL(p.total_plans, 0))
57835803
+ ' total plans in your cache, with '

sp_BlitzFirst.sql

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BEGIN
4242
SET NOCOUNT ON;
4343
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
4444

45-
SELECT @Version = '7.6', @VersionDate = '20190702';
45+
SELECT @Version = '7.7', @VersionDate = '20190826';
4646

4747
IF(@VersionCheckMode = 1)
4848
BEGIN
@@ -294,6 +294,7 @@ BEGIN
294294
a tool that relies on the output of sp_BlitzFirst.
295295
*/
296296

297+
297298
IF OBJECT_ID('tempdb..#BlitzFirstResults') IS NOT NULL
298299
DROP TABLE #BlitzFirstResults;
299300
CREATE TABLE #BlitzFirstResults
@@ -997,6 +998,21 @@ BEGIN
997998
END;
998999
END;
9991000

1001+
IF OBJECT_ID('tempdb..#ReadableDBs') IS NOT NULL
1002+
DROP TABLE #ReadableDBs;
1003+
CREATE TABLE #ReadableDBs (
1004+
database_id INT
1005+
);
1006+
1007+
IF EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
1008+
BEGIN
1009+
RAISERROR('Checking for Read intent databases to exclude',0,0) WITH NOWAIT;
1010+
1011+
SET @StringToExecute = 'INSERT INTO #ReadableDBs (database_id) SELECT DBs.database_id FROM sys.databases DBs INNER JOIN sys.availability_replicas Replicas ON DBs.replica_id = Replicas.replica_id WHERE replica_server_name NOT IN (SELECT DISTINCT primary_replica FROM sys.dm_hadr_availability_group_states States) AND Replicas.secondary_role_allow_connections_desc = ''READ_ONLY'' AND replica_server_name = @@SERVERNAME;';
1012+
EXEC(@StringToExecute);
1013+
1014+
END
1015+
10001016

10011017
SET @StockWarningHeader = '<?ClickToSeeCommmand -- ' + @LineFeed + @LineFeed
10021018
+ 'WARNING: Running this command may result in data loss or an outage.' + @LineFeed
@@ -1309,7 +1325,8 @@ BEGIN
13091325
AND request_owner_type = N'SHARED_TRANSACTION_WORKSPACE') AS db ON s.session_id = db.request_session_id
13101326
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) pl
13111327
WHERE r.command LIKE 'BACKUP%'
1312-
AND r.start_time <= DATEADD(minute, -5, GETDATE());
1328+
AND r.start_time <= DATEADD(minute, -5, GETDATE())
1329+
AND r.database_id NOT IN (SELECT database_id FROM #ReadableDBs);
13131330

13141331
/* If there's a backup running, add details explaining how long full backup has been taking in the last month. */
13151332
IF @Seconds > 0 AND CAST(SERVERPROPERTY('edition') AS VARCHAR(100)) <> 'SQL Azure'
@@ -1351,7 +1368,9 @@ BEGIN
13511368
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) pl
13521369
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
13531370
WHERE r.command LIKE 'DBCC%'
1354-
AND CAST(t.text AS NVARCHAR(4000)) NOT LIKE '%dm_db_index_physical_stats%';
1371+
AND CAST(t.text AS NVARCHAR(4000)) NOT LIKE '%dm_db_index_physical_stats%'
1372+
AND CAST(t.text AS NVARCHAR(4000)) NOT LIKE '%ALTER INDEX%'
1373+
AND r.database_id NOT IN (SELECT database_id FROM #ReadableDBs);
13551374

13561375

13571376
/* Maintenance Tasks Running - Restore Running - CheckID 3 */
@@ -1384,7 +1403,8 @@ BEGIN
13841403
AND request_status = N'GRANT') AS db ON s.session_id = db.request_session_id
13851404
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) pl
13861405
WHERE r.command LIKE 'RESTORE%'
1387-
AND s.program_name <> 'SQL Server Log Shipping';
1406+
AND s.program_name <> 'SQL Server Log Shipping'
1407+
AND r.database_id NOT IN (SELECT database_id FROM #ReadableDBs);
13881408

13891409

13901410
/* SQL Server Internal Maintenance - Database File Growing - CheckID 4 */
@@ -1411,7 +1431,8 @@ BEGIN
14111431
INNER JOIN sys.dm_exec_requests r ON t.session_id = r.session_id
14121432
INNER JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
14131433
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) pl
1414-
WHERE t.wait_type = 'PREEMPTIVE_OS_WRITEFILEGATHER';
1434+
WHERE t.wait_type = 'PREEMPTIVE_OS_WRITEFILEGATHER'
1435+
AND r.database_id NOT IN (SELECT database_id FROM #ReadableDBs);
14151436

14161437

14171438
/* Query Problems - Long-Running Query Blocking Others - CheckID 5 */
@@ -1446,10 +1467,11 @@ BEGIN
14461467
INNER JOIN sys.dm_exec_connections c ON s.session_id = c.session_id
14471468
WHERE tBlocked.wait_type LIKE ''LCK%'' AND tBlocked.wait_duration_ms > 30000
14481469
/* And the blocking session ID is not blocked by anyone else: */
1449-
AND NOT EXISTS(SELECT * FROM sys.dm_os_waiting_tasks tBlocking WHERE s.session_id = tBlocking.session_id AND tBlocking.session_id <> tBlocking.blocking_session_id AND tBlocking.blocking_session_id IS NOT NULL);';
1470+
AND NOT EXISTS(SELECT * FROM sys.dm_os_waiting_tasks tBlocking WHERE s.session_id = tBlocking.session_id AND tBlocking.session_id <> tBlocking.blocking_session_id AND tBlocking.blocking_session_id IS NOT NULL)
1471+
AND r.database_id NOT IN (SELECT database_id FROM #ReadableDBs);';
14501472
EXECUTE sp_executesql @StringToExecute;
14511473
END;
1452-
1474+
14531475
/* Query Problems - Plan Cache Erased Recently */
14541476
IF DATEADD(mi, -15, SYSDATETIME()) < (SELECT TOP 1 creation_time FROM sys.dm_exec_query_stats ORDER BY creation_time)
14551477
BEGIN
@@ -1674,7 +1696,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
16741696

16751697
/* Server Info - Memory Grant/Workspace info - CheckID 40 */
16761698
DECLARE @MaxWorkspace BIGINT
1677-
SET @MaxWorkspace = (SELECT CAST(cntr_value AS INT)/1024 FROM #PerfmonStats WHERE counter_name = N'Maximum Workspace Memory (KB)')
1699+
SET @MaxWorkspace = (SELECT CAST(cntr_value AS BIGINT)/1024 FROM #PerfmonStats WHERE counter_name = N'Maximum Workspace Memory (KB)')
16781700

16791701
IF (@MaxWorkspace IS NULL
16801702
OR @MaxWorkspace = 0)
@@ -3960,4 +3982,4 @@ EXEC sp_BlitzFirst
39603982
, @OutputTableNamePerfmonStats = 'BlitzFirst_PerfmonStats'
39613983
, @OutputTableNameWaitStats = 'BlitzFirst_WaitStats'
39623984
, @OutputTableNameBlitzCache = 'BlitzCache'
3963-
*/
3985+
*/

sp_BlitzInMemoryOLTP.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
8282
*/
8383
AS
8484
DECLARE @ScriptVersion VARCHAR(30);
85-
SELECT @ScriptVersion = '1.9', @VersionDate = '20190702';
85+
SELECT @ScriptVersion = '1.9', @VersionDate = '20190826';
8686

8787
IF(@VersionCheckMode = 1)
8888
BEGIN

0 commit comments

Comments
 (0)