@@ -569,6 +569,7 @@ SELECT 1320 AS tip_id,
569569 ' , updateability: ' , CAST (DATABASEPROPERTYEX (DB_NAME (), ' Updateability' ) AS nvarchar (10 )),
570570 ' , logical database GUID: ' , rg .logical_database_guid ,
571571 ' , physical database GUID: ' , rg .physical_database_guid ,
572+ ' , script execution timestamp (UTC): ' , CONVERT (varchar (20 ), SYSUTCDATETIME (), 120 ),
572573 @CRLF, @CRLF,
573574 STRING_AGG (
574575 CAST (CONCAT (
@@ -1009,7 +1010,7 @@ IF EXISTS (SELECT 1 FROM @TipDefinition WHERE tip_id IN (1140) AND execute_indic
10091010WITH allocated_used_space AS
10101011(
10111012SELECT SUM (CAST (size AS bigint ) * 8 / 1024 .) AS space_allocated_mb,
1012- SUM (CAST (FILEPROPERTY (name , ' SpaceUsed' ) AS bigint )) / 1024 . / 1024 AS space_used_mb
1013+ SUM (CAST (FILEPROPERTY (name , ' SpaceUsed' ) AS bigint )) * 8 / 1024 . AS space_used_mb
10131014FROM sys .database_files
10141015WHERE type_desc = ' ROWS'
10151016)
@@ -1022,7 +1023,7 @@ SELECT 1140 AS tip_id,
10221023 @CRLF
10231024 )
10241025FROM allocated_used_space
1025- WHERE space_used_mb * 8 / 1024 . > @UsedToAllocatedSpaceDbMinSizeMB -- not relevant for small databases
1026+ WHERE space_used_mb > @UsedToAllocatedSpaceDbMinSizeMB -- not relevant for small databases
10261027 AND
10271028 @UsedToAllocatedSpaceThresholdRatio * space_allocated_mb > space_used_mb -- allocated space is more than N times used space
10281029 AND
@@ -2615,7 +2616,13 @@ SELECT STRING_AGG(
26152616 ' , row overflow: ' , FORMAT (partition_range_row_overflow_size_mb, ' N' ),
26162617 ' , LOB: ' , FORMAT (partition_range_lob_size_mb, ' N' ),
26172618 ' ), present compression type: ' , present_compression_type,
2618- ' , suggested compression type: ' , new_compression_type
2619+ ' , suggested compression type: ' , new_compression_type,
2620+ ' , index rebuild statement: ' , CONCAT (
2621+ ' ALTER INDEX ' , index_name, ' ON ' , schema_name , ' .' , object_name ,
2622+ ' REBUILD' , IIF (partition_range = ' 1-1' , ' ' , CONCAT (' PARTITION = <' , partition_range, ' >' )),
2623+ ' WITH (' , ' DATA_COMPRESSION = ' , new_compression_type, ' ,' ,
2624+ ' ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 15 MINUTES, ABORT_AFTER_WAIT = SELF)), RESUMABLE = ON);'
2625+ )
26192626 ) AS nvarchar (max )), @CRLF
26202627 )
26212628 WITHIN GROUP (ORDER BY object_size_mb DESC , object_name , index_name, partition_range, partition_range_total_size_mb, new_compression_type)
@@ -3428,7 +3435,7 @@ ON t.object_id = ius.object_id
34283435 i .index_id = ius .index_id
34293436WHERE i .type IN (0 ,1 ) -- clustered index or heap
34303437 AND
3431- tos .table_size_mb > @CCICandidateMinSizeGB / 1024 . -- consider sufficiently large tables only
3438+ tos .table_size_mb > @CCICandidateMinSizeGB * 1024 . -- consider sufficiently large tables only
34323439 AND
34333440 t .is_ms_shipped = 0
34343441 AND
0 commit comments