Skip to content

Commit

Permalink
Ignore already fully compressed columnstore indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiisyrovatchenko committed Nov 14, 2021
1 parent 4023632 commit df1e3e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Server/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ CROSS APPLY sys.dm_db_index_physical_stats(@DBID, i.ObjectID, i.IndexID, i.Parti
FROM (
SELECT IndexID = [index_id]
, PartitionNumber = [partition_number]
, PagesCount = SUM([size_in_bytes]) / 8192
, PagesCount = ISNULL(SUM([size_in_bytes]), 0) / 8192
, UnusedPagesCount = ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) / 8192
, Fragmentation = CAST(ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) * 100. / SUM([size_in_bytes]) AS FLOAT)
, Fragmentation = ISNULL(CAST(ISNULL(SUM(CASE WHEN [state] = 1 THEN [size_in_bytes] END), 0) * 100. / SUM([size_in_bytes]) AS FLOAT), 0)
FROM sys.fn_column_store_row_groups(@ObjectID)
GROUP BY [index_id]
, [partition_number]
Expand Down
2 changes: 1 addition & 1 deletion Server/QueryEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public static void FindDublicateIndexes(List<Index> indexes) {
}

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

if (ix.IndexType == IndexType.MISSING_INDEX)
Expand Down

0 comments on commit df1e3e6

Please sign in to comment.