Skip to content

Commit

Permalink
removed singleton_lookup_count from calculations
Browse files Browse the repository at this point in the history
also removed parameter @MinimumScanPctForComparison from the main script
  • Loading branch information
EitanBlumin committed Jun 20, 2024
1 parent ac140fe commit afd2255
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 2 additions & 4 deletions Indexes/Check Compression Candidate - Single Table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ SELECT
ISNULL(ios.leaf_delete_count,0) +
ISNULL(ios.leaf_insert_count,0) +
ISNULL(ios.leaf_page_merge_count,0) +
ISNULL(ios.leaf_update_count,0) +
ISNULL(ios.singleton_lookup_count,0)
ISNULL(ios.leaf_update_count,0)
), 0) * 100.0), 0)
, updates_percent = ISNULL(
CEILING(SUM(ISNULL(ios.leaf_update_count, 0)) * 1.0 /
Expand All @@ -35,8 +34,7 @@ SELECT
ISNULL(ios.leaf_delete_count,0) +
ISNULL(ios.leaf_insert_count,0) +
ISNULL(ios.leaf_page_merge_count,0) +
ISNULL(ios.leaf_update_count,0) +
ISNULL(ios.singleton_lookup_count,0)
ISNULL(ios.leaf_update_count,0)
), 0) * 100.0), 0)
, size_MB = CEILING(SUM(ISNULL(sps.in_row_data_page_count,0) + ISNULL(sps.row_overflow_used_page_count,0) + ISNULL(sps.lob_reserved_page_count,0)) / 128.0)
, in_row_percent = ISNULL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
----------------------------------------------------------------
-- Change Log:
-- -----------
-- 2024-06-20 - removed parameter @MinimumScanPctForComparison; removed singleton_lookup_count from calculation.
-- 2021-09-09 - added check for incompatible options SortInTempDB and ResumableBuild being both enabled
-- 2021-09-06 - added @ResumableRebuild parameter
-- 2021-09-01 - some minor bug fixes and code quality fixes
Expand Down Expand Up @@ -98,7 +99,6 @@ DECLARE
-- Threshold parameters controlling recommendation algorithms based on partition stats:
,@MinimumCompressibleDataPercent INT = 45 -- Minimum percent of compressible in-row data, in order to consider any compression
,@MaximumUpdatePctAsInfrequent INT = 10 -- Maximum percent of updates for all operations to consider as "infrequent updates"
,@MinimumScanPctForComparison INT = 5 -- Minimum percent of range scans before considering to compare between update and scan percentages
,@MinimumScanPctForPage INT = 40 -- Minimum percent of scans when comparing to update percent, to deem PAGE compression preferable (otherwise, ROW compression will be preferable)
,@MaximumUpdatePctForPage INT = 40 -- Maximum percent of updates when comparing to scan percent, to deem PAGE compression preferable
,@MaximumUpdatePctForRow INT = 60 -- Maximum percent of updates when comparing to scan percent, to deem ROW compression preferable
Expand Down Expand Up @@ -176,7 +176,6 @@ FROM
,('@CompressionRatioThreshold',@CompressionRatioThreshold)
,('@MinimumRatioDifferenceForPage',@MinimumRatioDifferenceForPage)
,('@MaximumUpdatePctAsInfrequent',@MaximumUpdatePctAsInfrequent)
,('@MinimumScanPctForComparison',@MinimumScanPctForComparison)
,('@MaximumCPUPercentForRebuild',ISNULL(@MaximumCPUPercentForRebuild,100))
) AS v(VarName,VarValue)
WHERE VarValue NOT BETWEEN 1 AND 100 OR VarValue IS NULL
Expand Down Expand Up @@ -420,8 +419,7 @@ SELECT
ISNULL(ios.leaf_delete_count,0) +
ISNULL(ios.leaf_insert_count,0) +
ISNULL(ios.leaf_page_merge_count,0) +
ISNULL(ios.leaf_update_count,0) +
ISNULL(ios.singleton_lookup_count,0)
ISNULL(ios.leaf_update_count,0)
), 0) * 100.0), 0)
, updates_percent = ISNULL(
CEILING(SUM(ISNULL(ios.leaf_update_count, 0)) * 1.0 /
Expand All @@ -430,8 +428,7 @@ SELECT
ISNULL(ios.leaf_delete_count,0) +
ISNULL(ios.leaf_insert_count,0) +
ISNULL(ios.leaf_page_merge_count,0) +
ISNULL(ios.leaf_update_count,0) +
ISNULL(ios.singleton_lookup_count,0)
ISNULL(ios.leaf_update_count,0)
), 0) * 100.0), 0)
FROM #objects AS p WITH(NOLOCK)
OUTER APPLY sys.dm_db_index_operational_stats(db_id(),p.object_id,p.index_id,p.partition_number) AS ios
Expand Down Expand Up @@ -502,7 +499,7 @@ BEGIN

SET @EstimationCheckRecommended = CASE
WHEN @InRowPercent < @MinimumCompressibleDataPercent THEN 0
WHEN ISNULL(@ScanPercent,0) <= @MinimumScanPctForComparison OR ISNULL(@UpdatePercent,0) <= @MaximumUpdatePctAsInfrequent THEN 1
WHEN ISNULL(@UpdatePercent,0) <= @MaximumUpdatePctAsInfrequent THEN 1
WHEN @CompressionType = 'PAGE' AND @ScanPercent >= @MinimumScanPctForPage AND @UpdatePercent <= @MaximumUpdatePctForPage THEN 1
WHEN @CompressionType = 'ROW' AND @UpdatePercent <= @MaximumUpdatePctForRow THEN 1
ELSE 0
Expand Down Expand Up @@ -646,7 +643,7 @@ SELECT
WHEN is_compression_recommended IS NULL AND is_compression_feasible = 1 THEN
CASE
WHEN in_row_percent < @MinimumCompressibleDataPercent THEN N'No'
WHEN compression_type = 'PAGE' AND ISNULL(scan_percent,0) <= @MinimumScanPctForComparison AND ISNULL(update_percent,0) <= @MaximumUpdatePctAsInfrequent THEN 'Yes'
WHEN compression_type = 'PAGE' AND ISNULL(update_percent,0) <= @MaximumUpdatePctAsInfrequent THEN 'Yes'
WHEN scan_percent >= @MinimumScanPctForPage AND update_percent <= @MaximumUpdatePctForPage THEN
CASE WHEN compression_type = 'PAGE' THEN 'Yes' ELSE 'No' END
WHEN update_percent <= @MaximumUpdatePctForRow THEN
Expand Down

0 comments on commit afd2255

Please sign in to comment.