From b81867e5835350918eab5aed3000124170886f5c Mon Sep 17 00:00:00 2001 From: DCrawford Date: Fri, 29 Oct 2021 16:16:29 -0400 Subject: [PATCH] Add files via upload --- Synapse/SynapseCCIGuidance/FindSmallCCITables.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Synapse/SynapseCCIGuidance/FindSmallCCITables.sql diff --git a/Synapse/SynapseCCIGuidance/FindSmallCCITables.sql b/Synapse/SynapseCCIGuidance/FindSmallCCITables.sql new file mode 100644 index 0000000..96479b0 --- /dev/null +++ b/Synapse/SynapseCCIGuidance/FindSmallCCITables.sql @@ -0,0 +1,15 @@ +SELECT sm.name as [Schema_Name] +, tb.[name] AS [logical_table_name] +, sum(rg.[total_rows]) AS [total_CCI_rows] +FROM sys.[schemas] sm +JOIN sys.[tables] tb ON sm.[schema_id] = tb.[schema_id] +JOIN sys.[pdw_table_mappings] mp ON tb.[object_id] = mp.[object_id] +JOIN sys.[pdw_nodes_tables] nt ON nt.[name] = mp.[physical_name] +JOIN sys.[dm_pdw_nodes_db_column_store_row_group_physical_stats] rg ON rg.[object_id] = nt.[object_id] + AND rg.[pdw_node_id] = nt.[pdw_node_id] + AND rg.[distribution_id] = nt.[distribution_id] +GROUP BY sm.name, tb.name, rg.[object_id], index_id +HAVING sum(rg.[total_rows]) < 60000000 -- Show only CCI tables with less than 60m records +; + +-- https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-index#optimizing-clustered-columnstore-indexes \ No newline at end of file