You've already forked ssms-addin
mirror of
https://github.com/alex-bochkov/ssms-addin.git
synced 2026-06-15 16:57:06 +02:00
Update column-store-indexes.sql
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
-- select all columnstore indexes
|
-- select all columnstore indexes
|
||||||
SELECT
|
SELECT
|
||||||
OBJECT_SCHEMA_NAME(OBJECT_ID) SchemaName,
|
OBJECT_SCHEMA_NAME(OBJECT_ID) SchemaName,
|
||||||
@@ -18,19 +19,22 @@ SELECT *
|
|||||||
FROM sys.dm_db_column_store_row_group_physical_stats
|
FROM sys.dm_db_column_store_row_group_physical_stats
|
||||||
WHERE object_id = object_id('TableName')
|
WHERE object_id = object_id('TableName')
|
||||||
ORDER BY row_group_id;
|
ORDER BY row_group_id;
|
||||||
|
*/
|
||||||
-- get some stats around CIX - helps to see which partitions need to be rebuilt
|
-- get some stats around CIX - helps to see which partitions need to be rebuilt
|
||||||
SELECT OBJECT_SCHEMA_NAME(ps.[object_id]) AS schemaName,
|
SELECT OBJECT_SCHEMA_NAME(ps.[object_id]) AS schemaName,
|
||||||
OBJECT_NAME(ps.[object_id]) AS tableName,
|
OBJECT_NAME(ps.[object_id]) AS tableName,
|
||||||
ps.partition_number,
|
ps.partition_number,
|
||||||
|
p.data_compression_desc,
|
||||||
FORMAT(SUM(ps.row_group_id), 'N0') AS row_group_count,
|
FORMAT(SUM(ps.row_group_id), 'N0') AS row_group_count,
|
||||||
FORMAT(SUM(ps.total_rows), 'N0') AS row_count,
|
FORMAT(SUM(ps.total_rows), 'N0') AS row_count,
|
||||||
FORMAT(SUM(ps.deleted_rows), 'N0') AS deleted_rows,
|
FORMAT(SUM(ps.deleted_rows), 'N0') AS deleted_rows,
|
||||||
FORMAT(SUM(ps.size_in_bytes), 'N0') AS size_in_bytes,
|
FORMAT(SUM(ps.size_in_bytes) / 1024 / 1024, 'N0') AS size_in_mbytes,
|
||||||
FORMAT(SUM(ps.size_in_bytes) / sum(total_rows), 'N0') AS size_per_row,
|
FORMAT(SUM(ps.size_in_bytes) / sum(total_rows), 'N0') AS size_per_row,
|
||||||
CONCAT('ALTER INDEX [', i.[name], '] ON ', OBJECT_SCHEMA_NAME(ps.[object_id]), '.', OBJECT_NAME(ps.[object_id]), ' REBUILD PARTITION = ', ps.partition_number, ' WITH (DATA_COMPRESSION = COLUMNSTORE, ONLINE = ON, SORT_IN_TEMPDB = ON, /* MAXDOP = 8 */);
|
CONCAT('ALTER INDEX [', i.[name], '] ON ', OBJECT_SCHEMA_NAME(ps.[object_id]), '.', OBJECT_NAME(ps.[object_id]),
|
||||||
|
' REBUILD PARTITION = ', ps.partition_number, ' WITH (DATA_COMPRESSION = COLUMNSTORE, ONLINE = ON, SORT_IN_TEMPDB = ON /*, MAXDOP = 8 */);
|
||||||
GO') AS rebuiltCommand
|
GO') AS rebuiltCommand
|
||||||
FROM sys.dm_db_column_store_row_group_physical_stats AS ps
|
FROM sys.dm_db_column_store_row_group_physical_stats AS ps
|
||||||
INNER JOIN sys.indexes AS i ON ps.[object_id] = i.[object_id] AND ps.index_id = i.index_id
|
INNER JOIN sys.indexes AS i ON ps.[object_id] = i.[object_id] AND ps.index_id = i.index_id
|
||||||
GROUP BY ps.[object_id], ps.partition_number, i.[name]
|
INNER JOIN sys.partitions p ON ps.partition_number = p.partition_number AND ps.[object_id] = p.[object_id] AND ps.index_id = p.index_id
|
||||||
ORDER BY ps.partition_number;
|
GROUP BY ps.[object_id], ps.partition_number, p.data_compression_desc, i.[name]
|
||||||
|
ORDER BY schemaName, tableName, ps.partition_number;
|
||||||
|
|||||||
Reference in New Issue
Block a user