Skip to content

Commit ec6b770

Browse files
committed
Bug fixes and performance improvements
-Changed index_sanity_id to be NULLable in #IndexPartitionSanity -Changed version check to only ever use LEFT JOIN query to get partition information. This was taking upwards of 6 minutes with 15k partitions.
1 parent 7d344c0 commit ec6b770

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sp_BlitzIndex.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ Changes in v4.0 - YYYY/MM/DD:
7171
old output parameter @Version is no more, because we are switching to
7272
semantic versioning.
7373
https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/284
74+
- Bug fixes and improvements
75+
- Erik Darling:
76+
-Changed index_sanity_id to be NULLable in #IndexPartitionSanity
77+
-Changed version check to only ever use LEFT JOIN query to get partition information.
78+
This was taking upwards of 6 minutes with 15k partitions.
7479
7580
Changes in v3.0 - 2016/03/20:
7681
- Prioritized results
@@ -266,7 +271,7 @@ IF OBJECT_ID('tempdb..#DatabaseList') IS NOT NULL
266271
CREATE TABLE #IndexSanitySize
267272
(
268273
[index_sanity_size_id] INT IDENTITY NOT NULL ,
269-
[index_sanity_id] INT NOT NULL ,
274+
[index_sanity_id] INT NULL ,
270275
[database_id] INT NOT NULL,
271276
partition_count INT NOT NULL ,
272277
total_rows BIGINT NOT NULL ,
@@ -806,10 +811,10 @@ BEGIN TRY
806811

807812
IF (SELECT LEFT(@SQLServerProductVersion,
808813
CHARINDEX('.',@SQLServerProductVersion,0)-1
809-
)) <> 11 --Anything other than 2012
814+
)) <= 2147483647 --Anything other than 2012
810815
BEGIN
811816

812-
RAISERROR (N'Using non-2012 syntax to query sys.dm_db_index_operational_stats',0,1) WITH NOWAIT;
817+
RAISERROR (N'Preferring non-2012 syntax with LEFT JOIN to sys.dm_db_index_operational_stats',0,1) WITH NOWAIT;
813818

814819
--NOTE: we're joining to sys.dm_db_index_operational_stats differently than you might think (not using a cross apply)
815820
--This is because of quirks prior to SQL Server 2012 and in 2014 with this DMV.

0 commit comments

Comments
 (0)