Skip to content

Commit 2077906

Browse files
authored
Merge pull request #3295 from BrentOzarULTD/3294_sp_BlitzIndex_more_columnstore
#3294 sp_BlitzIndex columnstore
2 parents 05f99cc + 4bb9866 commit 2077906

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sp_BlitzIndex.sql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,7 +2958,8 @@ BEGIN
29582958
+ CASE WHEN @ShowPartitionRanges = 1 THEN N' COALESCE(range_start_op + '' '' + range_start + '' '', '''') + COALESCE(range_end_op + '' '' + range_end, '''') AS partition_range, ' ELSE N' ' END
29592959
+ N' row_group_id, total_rows, deleted_rows, '
29602960
+ @ColumnList
2961-
+ CASE WHEN @ShowPartitionRanges = 1 THEN N'
2961+
+ CASE WHEN @ShowPartitionRanges = 1 THEN N' ,
2962+
state_desc, trim_reason_desc, transition_to_compressed_state_desc, has_vertipaq_optimization
29622963
FROM (
29632964
SELECT column_name, partition_number, row_group_id, total_rows, deleted_rows, details,
29642965
range_start_op,
@@ -2968,10 +2969,12 @@ BEGIN
29682969
range_end_op,
29692970
CASE
29702971
WHEN format_type IS NULL THEN CAST(range_end_value AS NVARCHAR(4000))
2971-
ELSE CONVERT(NVARCHAR(4000), range_end_value, format_type) END range_end' ELSE N' ' END + N'
2972+
ELSE CONVERT(NVARCHAR(4000), range_end_value, format_type) END range_end' ELSE N' ' END + N',
2973+
state_desc, trim_reason_desc, transition_to_compressed_state_desc, has_vertipaq_optimization
29722974
FROM (
29732975
SELECT c.name AS column_name, p.partition_number, rg.row_group_id, rg.total_rows, rg.deleted_rows,
2974-
details = CAST(seg.min_data_id AS VARCHAR(20)) + '' to '' + CAST(seg.max_data_id AS VARCHAR(20)) + '', '' + CAST(CAST((seg.on_disk_size / 1024.0 / 1024) AS DECIMAL(18,0)) AS VARCHAR(20)) + '' MB'''
2976+
phys.state_desc, phys.trim_reason_desc, phys.transition_to_compressed_state_desc, phys.has_vertipaq_optimization,
2977+
details = CAST(seg.min_data_id AS VARCHAR(20)) + '' to '' + CAST(seg.max_data_id AS VARCHAR(20)) + '', '' + CAST(CAST(((COALESCE(d.on_disk_size,0) + COALESCE(seg.on_disk_size,0)) / 1024.0 / 1024) AS DECIMAL(18,0)) AS VARCHAR(20)) + '' MB'''
29752978
+ CASE WHEN @ShowPartitionRanges = 1 THEN N',
29762979
CASE
29772980
WHEN pp.system_type_id IN (40, 41, 42, 43, 58, 61) THEN 126
@@ -2985,14 +2988,16 @@ BEGIN
29852988
FROM ' + QUOTENAME(@DatabaseName) + N'.sys.column_store_row_groups rg
29862989
INNER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.columns c ON rg.object_id = c.object_id
29872990
INNER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partitions p ON rg.object_id = p.object_id AND rg.partition_number = p.partition_number
2988-
INNER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.index_columns ic on ic.column_id = c.column_id AND ic.object_id = c.object_id AND ic.index_id = p.index_id ' + CASE WHEN @ShowPartitionRanges = 1 THEN N'
2991+
INNER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.index_columns ic on ic.column_id = c.column_id AND ic.object_id = c.object_id AND ic.index_id = p.index_id
2992+
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.dm_db_column_store_row_group_physical_stats phys ON rg.row_group_id = phys.row_group_id AND rg.object_id = phys.object_id AND rg.partition_number = phys.partition_number AND p.index_id = phys.index_id ' + CASE WHEN @ShowPartitionRanges = 1 THEN N'
29892993
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.indexes i ON i.object_id = rg.object_id AND i.index_id = rg.index_id
29902994
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partition_schemes ps ON ps.data_space_id = i.data_space_id
29912995
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partition_functions pf ON pf.function_id = ps.function_id
29922996
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partition_parameters pp ON pp.function_id = pf.function_id
29932997
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partition_range_values prvs ON prvs.function_id = pf.function_id AND prvs.boundary_id = p.partition_number - 1
29942998
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.partition_range_values prve ON prve.function_id = pf.function_id AND prve.boundary_id = p.partition_number ' ELSE N' ' END
29952999
+ N' LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.column_store_segments seg ON p.partition_id = seg.partition_id AND ic.index_column_id = seg.column_id AND rg.row_group_id = seg.segment_id
3000+
LEFT OUTER JOIN ' + QUOTENAME(@DatabaseName) + N'.sys.column_store_dictionaries d ON p.hobt_id = d.hobt_id AND c.column_id = d.column_id AND seg.secondary_dictionary_id = d.dictionary_id
29963001
WHERE rg.object_id = @ObjectID
29973002
AND rg.state IN (1, 2, 3)
29983003
AND c.name IN ( ' + @ColumnListWithApostrophes + N')'
@@ -3030,6 +3035,9 @@ BEGIN
30303035
RAISERROR(N'Done visualizing columnstore index contents.', 0,1) WITH NOWAIT;
30313036
END
30323037

3038+
IF @ShowColumnstoreOnly = 1
3039+
RETURN;
3040+
30333041
END; /* IF @TableName IS NOT NULL */
30343042

30353043

0 commit comments

Comments
 (0)