Skip to content

Commit 53290c3

Browse files
Merge pull request #65 from microsoft/dev
Fixed 1290, small changes to output of 1180 and 1320
2 parents 37841f5 + 588d02d commit 53290c3

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

sqldb-tips/get-sqldb-tips-compat-level-100-only.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ SELECT 1320 AS tip_id,
580580
', updateability: ', CAST(DATABASEPROPERTYEX(DB_NAME(), 'Updateability') AS nvarchar(10)),
581581
', logical database GUID: ', rg.logical_database_guid,
582582
', physical database GUID: ', rg.physical_database_guid,
583+
', script execution timestamp (UTC): ', CONVERT(varchar(20), SYSUTCDATETIME(), 120),
583584
@CRLF, @CRLF,
584585
STRING_AGG(
585586
CAST(CONCAT(
@@ -1018,7 +1019,7 @@ IF EXISTS (SELECT 1 FROM @TipDefinition WHERE tip_id IN (1140) AND execute_indic
10181019
WITH allocated_used_space AS
10191020
(
10201021
SELECT SUM(CAST(size AS bigint) * 8 / 1024.) AS space_allocated_mb,
1021-
SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS bigint)) / 1024. / 1024 AS space_used_mb
1022+
SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS bigint)) * 8 / 1024. AS space_used_mb
10221023
FROM sys.database_files
10231024
WHERE type_desc = 'ROWS'
10241025
)
@@ -1031,7 +1032,7 @@ SELECT 1140 AS tip_id,
10311032
@CRLF
10321033
)
10331034
FROM allocated_used_space
1034-
WHERE space_used_mb * 8 / 1024. > @UsedToAllocatedSpaceDbMinSizeMB -- not relevant for small databases
1035+
WHERE space_used_mb > @UsedToAllocatedSpaceDbMinSizeMB -- not relevant for small databases
10351036
AND
10361037
@UsedToAllocatedSpaceThresholdRatio * space_allocated_mb > space_used_mb -- allocated space is more than N times used space
10371038
AND
@@ -2620,7 +2621,13 @@ SELECT STRING_AGG(
26202621
', row overflow: ', FORMAT(partition_range_row_overflow_size_mb, 'N'),
26212622
', LOB: ', FORMAT(partition_range_lob_size_mb, 'N'),
26222623
'), present compression type: ', present_compression_type,
2623-
', suggested compression type: ', new_compression_type
2624+
', suggested compression type: ', new_compression_type,
2625+
', index rebuild statement: ', CONCAT(
2626+
'ALTER INDEX ', index_name, ' ON ', schema_name, '.', object_name,
2627+
' REBUILD', IIF(partition_range = '1-1', '', CONCAT(' PARTITION = <', partition_range, '>')),
2628+
' WITH (', 'DATA_COMPRESSION = ', new_compression_type, ',',
2629+
' ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 15 MINUTES, ABORT_AFTER_WAIT = SELF)), RESUMABLE = ON);'
2630+
)
26242631
) AS nvarchar(max)), @CRLF
26252632
)
26262633
AS details
@@ -3430,7 +3437,7 @@ ON t.object_id = ius.object_id
34303437
i.index_id = ius.index_id
34313438
WHERE i.type IN (0,1) -- clustered index or heap
34323439
AND
3433-
tos.table_size_mb > @CCICandidateMinSizeGB / 1024. -- consider sufficiently large tables only
3440+
tos.table_size_mb > @CCICandidateMinSizeGB * 1024. -- consider sufficiently large tables only
34343441
AND
34353442
t.is_ms_shipped = 0
34363443
AND

sqldb-tips/get-sqldb-tips.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
10091010
WITH allocated_used_space AS
10101011
(
10111012
SELECT 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
10131014
FROM sys.database_files
10141015
WHERE type_desc = 'ROWS'
10151016
)
@@ -1022,7 +1023,7 @@ SELECT 1140 AS tip_id,
10221023
@CRLF
10231024
)
10241025
FROM 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
34293436
WHERE 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

Comments
 (0)