Skip to content

Commit df1e3e6

Browse files
Ignore already fully compressed columnstore indexes
1 parent 4023632 commit df1e3e6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Server/Query.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ CROSS APPLY sys.dm_db_index_physical_stats(@DBID, i.ObjectID, i.IndexID, i.Parti
585585
FROM (
586586
SELECT IndexID = [index_id]
587587
, PartitionNumber = [partition_number]
588-
, PagesCount = SUM([size_in_bytes]) / 8192
588+
, PagesCount = ISNULL(SUM([size_in_bytes]), 0) / 8192
589589
, UnusedPagesCount = ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) / 8192
590-
, Fragmentation = CAST(ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) * 100. / SUM([size_in_bytes]) AS FLOAT)
590+
, Fragmentation = ISNULL(CAST(ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) * 100. / SUM([size_in_bytes]) AS FLOAT), 0)
591591
FROM sys.fn_column_store_row_groups(@ObjectID)
592592
GROUP BY [index_id]
593593
, [partition_number]

Server/QueryEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public static void FindDublicateIndexes(List<Index> indexes) {
469469
}
470470

471471
private static IndexOp CorrectIndexOp(IndexOp op, Index ix) {
472-
if (op == IndexOp.NO_ACTION || op == IndexOp.IGNORE)
472+
if (op == IndexOp.NO_ACTION || op == IndexOp.IGNORE || (ix.IsColumnstore && ix.Fragmentation == 0))
473473
return IndexOp.SKIP;
474474

475475
if (ix.IndexType == IndexType.MISSING_INDEX)

0 commit comments

Comments
 (0)