浏览代码

v2.4.2

Fixed various string formatting issues (Thanks Alex Protesenko);
Updated Indexes with large keys check for SQL 2016+ (Thanks Petar Trbos);
Fixed PK violation in Foreign Keys with no Index check (Thanks Scott Ivey)
pmasl 6 年之前
父节点
当前提交
653ed52868
共有 2 个文件被更改,包括 19 次插入10 次删除
  1. 4 1
      BPCheck/Changelog.txt
  2. 15 9
      BPCheck/Check_BP_Servers.sql

+ 4 - 1
BPCheck/Changelog.txt

@@ -381,4 +381,7 @@ v2.4.1.5 - 06/06/2019 - Fixed table error with Query Store and Auto Tuning secti
 v2.4.1.5.1 - 06/25/2019 - Added batch mode syncpoint waits to wait stats section. 
 v2.4.1.5.1 - 06/25/2019 - Added batch mode syncpoint waits to wait stats section. 
 v2.4.1.6 - 08/20/2019 - Reviewed entire trace flag check section;
 v2.4.1.6 - 08/20/2019 - Reviewed entire trace flag check section;
 						Minor revisions to System configurations and Plan use ratio subsections.
 						Minor revisions to System configurations and Plan use ratio subsections.
-v2.4.1.6.1 - 08/21/2019 - Fixed syntax errors in trace flag section.
+v2.4.1.6.1 - 08/21/2019 - Fixed syntax errors in trace flag section.
+v2.4.2 - 08/28/2019 - Fixed various string formatting issues (Thanks Alex Protesenko);						
+						Updated Indexes with large keys check for SQL 2016+ (Thanks Petar Trbos);
+						Fixed PK violation in Foreign Keys with no Index check (Thanks Scott Ivey).

+ 15 - 9
BPCheck/Check_BP_Servers.sql

@@ -2457,7 +2457,8 @@ SELECT 'Pagefile_checks' AS [Category], 'Process_paged_out' AS [Check],
 IF @ptochecks = 1
 IF @ptochecks = 1
 RAISERROR (N'|-Starting I/O Checks', 10, 1) WITH NOWAIT
 RAISERROR (N'|-Starting I/O Checks', 10, 1) WITH NOWAIT
 
 
---------------------------------------------------------------------------------------------------------------------------OUT VARCHAR(20), all in database files over 50% of cumulative sampled time or I/O latencies over 20ms in the last 5s subsection
+--------------------------------------------------------------------------------------------------------------------------------
+-- I/O stall in database files over 50% of cumulative sampled time or I/O latencies over 20ms in the last 5s subsection
 -- io_stall refers to user processes waited for I/O. This number can be much greater than the sample_ms.
 -- io_stall refers to user processes waited for I/O. This number can be much greater than the sample_ms.
 -- Might indicate that your I/O has insufficient service capabilities (HBA queue depths, reduced throughput, etc). 
 -- Might indicate that your I/O has insufficient service capabilities (HBA queue depths, reduced throughput, etc). 
 --------------------------------------------------------------------------------------------------------------------------------
 --------------------------------------------------------------------------------------------------------------------------------
@@ -10584,18 +10585,23 @@ WHERE OBJECTPROPERTY(so.object_id,''IsUserTable'') = 1
 END;
 END;
 
 
 --------------------------------------------------------------------------------------------------------------------------------
 --------------------------------------------------------------------------------------------------------------------------------
--- Indexes with large keys (> 900 bytes) subsection
+-- Indexes with large keys (> 900 bytes for clustered index; 1700 bytes for nonclustered index) subsection
 --------------------------------------------------------------------------------------------------------------------------------
 --------------------------------------------------------------------------------------------------------------------------------
 IF @ptochecks = 1
 IF @ptochecks = 1
 BEGIN
 BEGIN
-	RAISERROR (N'  |-Starting Indexes with large keys (> 900 bytes)', 10, 1) WITH NOWAIT
-	IF (SELECT COUNT(*) FROM #tblIxs1 WHERE [KeyCols_data_length_bytes] > 900) > 0
+	RAISERROR (N'  |-Starting Indexes with large keys', 10, 1) WITH NOWAIT
+	IF (SELECT COUNT(*) FROM #tblIxs1 WHERE ([KeyCols_data_length_bytes] > 900 AND @sqlmajorver < 13)
+			OR ([KeyCols_data_length_bytes] > 900 AND indexType IN (1,5) AND @sqlmajorver >= 13)
+			OR ([KeyCols_data_length_bytes] > 1700 AND indexType IN (2,6) AND @sqlmajorver >= 13)) > 0
 	BEGIN
 	BEGIN
-		SELECT 'Index_and_Stats_checks' AS [Category], 'Large_Index_Key' AS [Check], '[WARNING: Some indexes have keys larger than 900 bytes. It is recommended to revise these]' AS [Deviation]
-		SELECT 'Index_and_Stats_checks' AS [Category], 'Large_Index_Key' AS [Information], I.[DatabaseName] AS [Database_Name], I.schemaName AS [Schema_Name], I.[objectName] AS [Table_Name], I.[indexID], I.[indexName] AS [Index_Name], 
-			I.KeyCols, [KeyCols_data_length_bytes]
+		SELECT 'Index_and_Stats_checks' AS [Category], 'Large_Index_Key' AS [Check], 
+			CASE WHEN @sqlmajorver < 13 THEN '[WARNING: Some indexes have keys larger than 900 bytes. It is recommended to revise these]' 
+				ELSE '[WARNING: Some indexes have keys larger than allowed (900 bytes for clustered index; 1700 bytes for nonclustered index). It is recommended to revise these]' END AS [Deviation]
+		SELECT 'Index_and_Stats_checks' AS [Category], 'Large_Index_Key' AS [Information], I.[DatabaseName] AS [Database_Name], I.schemaName AS [Schema_Name], I.[objectName] AS [Table_Name], I.[indexID], I.[indexName] AS [Index_Name], I.indexType, I.KeyCols, [KeyCols_data_length_bytes]
 		FROM #tblIxs1 I
 		FROM #tblIxs1 I
-		WHERE [KeyCols_data_length_bytes] > 900
+		WHERE ([KeyCols_data_length_bytes] > 900 AND @sqlmajorver < 13)
+			OR ([KeyCols_data_length_bytes] > 900 AND indexType IN (1,5) AND @sqlmajorver >= 13)
+			OR ([KeyCols_data_length_bytes] > 1700 AND indexType IN (2,6) AND @sqlmajorver >= 13)
 		ORDER BY I.[DatabaseName], I.schemaName, I.[objectName], I.[indexID]
 		ORDER BY I.[DatabaseName], I.schemaName, I.[objectName], I.[indexID]
 	END
 	END
 	ELSE
 	ELSE
@@ -10766,7 +10772,7 @@ BEGIN
 	IF NOT EXISTS (SELECT [object_id] FROM tempdb.sys.objects (NOLOCK) WHERE [object_id] = OBJECT_ID('tempdb.dbo.#tblFK'))
 	IF NOT EXISTS (SELECT [object_id] FROM tempdb.sys.objects (NOLOCK) WHERE [object_id] = OBJECT_ID('tempdb.dbo.#tblFK'))
 	CREATE TABLE #tblFK ([databaseID] int, [DatabaseName] sysname, [constraint_name] NVARCHAR(200), [parent_schema_name] NVARCHAR(100), 
 	CREATE TABLE #tblFK ([databaseID] int, [DatabaseName] sysname, [constraint_name] NVARCHAR(200), [parent_schema_name] NVARCHAR(100), 
 	[parent_table_name] NVARCHAR(200), parent_columns NVARCHAR(4000), [referenced_schema] NVARCHAR(100), [referenced_table_name] NVARCHAR(200), referenced_columns NVARCHAR(4000),
 	[parent_table_name] NVARCHAR(200), parent_columns NVARCHAR(4000), [referenced_schema] NVARCHAR(100), [referenced_table_name] NVARCHAR(200), referenced_columns NVARCHAR(4000),
-	CONSTRAINT PK_FK PRIMARY KEY CLUSTERED(databaseID, [constraint_name]))
+	CONSTRAINT PK_FK PRIMARY KEY CLUSTERED(databaseID, [constraint_name], [parent_schema_name]))
 	
 	
 	UPDATE #tmpdbs1
 	UPDATE #tmpdbs1
 	SET isdone = 0
 	SET isdone = 0