diff --git a/OCTPDBA-931 - Evaluate databases sizes for TPH consolidation in Azure SQL Hyperscale/compute detailed report.sql b/OCTPDBA-931 - Evaluate databases sizes for TPH consolidation in Azure SQL Hyperscale/compute detailed report.sql index d18cde7..45f15ac 100644 --- a/OCTPDBA-931 - Evaluate databases sizes for TPH consolidation in Azure SQL Hyperscale/compute detailed report.sql +++ b/OCTPDBA-931 - Evaluate databases sizes for TPH consolidation in Azure SQL Hyperscale/compute detailed report.sql @@ -89,7 +89,7 @@ ORDER BY [f].[Server Name], [f].[dbName] ; ---per customer +--per customer (number not formatted) WITH [cteFilteredSize] AS ( SELECT [d].[Server Name], [d].[dbName], @@ -145,4 +145,73 @@ GROUP BY CASE WHEN [d].[Server Name] LIKE 'sun%' OR [d].[Server Name] LIKE 'swsu%' THEN 'sun' ELSE 'central' END +ORDER BY CASE + WHEN COUNT(DISTINCT [f].[Server Name]) = 1 THEN 99 + ELSE 2 + END DESC, + MAX([f].[Server Name]) ASC +; + + +--per customer (number formatted) +WITH [cteFilteredSize] AS ( + SELECT [d].[Server Name], + [d].[dbName], + SUM([d].[UsedSpaceMB]) AS [filteredInstanceMBUsed] + FROM [dbo].[octpdba-931-detail] [d] + WHERE [d].[toIgnore] = 0 + GROUP BY [d].[server Name], + [d].[dbName] + ), + [cteUnfilteredSize] AS ( + SELECT [d].[Server Name], + [d].[dbName], + SUM([d].[UsedSpaceMB]) AS [unfilteredInstanceMBUsed] + FROM [dbo].[octpdba-931-detail] [d] + GROUP BY [d].[server Name], + [d].[dbName] + ), + [cteCurrentSize] AS ( + SELECT [g].[Server Name], + [g].[dbname], + SUM([g].[SpaceUsedMB]) [currentMbUsed] + FROM [dbo].[octpdba-931-global] [g] + GROUP BY [g].[Server Name], + [g].[dbname] + ), + [cteCompressedSize] AS ( + SELECT [d].[Server Name], + [d].[dbName], + SUM([d].[compressEstimateSpaceMB]) AS [filteredInstanceMBCompressionEstimate] + FROM [dbo].[octpdba-931-detail] [d] + WHERE [d].[toIgnore] = 0 + GROUP BY [d].[server Name], + [d].[dbName] + ) +SELECT CASE + WHEN [d].[Server Name] LIKE 'ama%' OR [d].[Server Name] LIKE 'swam%' THEN 'ama' + WHEN [d].[Server Name] LIKE 'cvi%' OR [d].[Server Name] LIKE 'swcv%' THEN 'cvi' + WHEN [d].[Server Name] LIKE 'sun%' OR [d].[Server Name] LIKE 'swsu%' THEN 'sun' + ELSE 'central' + END AS [customer], + COUNT(DISTINCT [f].[Server Name]) AS [cnt], + REPLACE(REPLACE(CONVERT(VARCHAR(100), CONVERT(MONEY,CAST(SUM([f].[filteredInstanceMBUsed]) AS NUMERIC(25, 2))), 1),',',''''),'.00','') AS [Filtered tables size in MB], + REPLACE(REPLACE(CONVERT(VARCHAR(100), CONVERT(MONEY,CAST(SUM([uf].[unfilteredInstanceMBUsed]) AS NUMERIC(25, 2))), 1),',',''''),'.00','') AS [Unfiltered tables size in MB], + REPLACE(REPLACE(CONVERT(VARCHAR(100), CONVERT(MONEY,CAST(SUM([c].[currentMbUsed]) AS NUMERIC(25, 2))), 1),',',''''),'.00','') AS [Current db size in MB], + REPLACE(REPLACE(CONVERT(VARCHAR(100), CONVERT(MONEY,CAST(SUM([d].[filteredInstanceMBCompressionEstimate]) AS NUMERIC(25, 2))), 1),',',''''),'.00','') AS [Estimated compressed db size in MB] +FROM [cteFilteredSize] [f] + INNER JOIN [cteUnfilteredSize] [uf] ON [uf].[Server Name] = [f].[Server Name] AND [uf].[dbName] = [f].[dbName] + INNER JOIN [cteCurrentSize] [c] ON [c].[Server Name] = [f].[Server Name] AND [c].[dbName] = [f].[dbName] + INNER JOIN [cteCompressedSize] [d] ON [d].[Server Name] = [f].[Server Name] AND [d].[dbName] = [f].[dbName] +GROUP BY CASE + WHEN [d].[Server Name] LIKE 'ama%' OR [d].[Server Name] LIKE 'swam%' THEN 'ama' + WHEN [d].[Server Name] LIKE 'cvi%' OR [d].[Server Name] LIKE 'swcv%' THEN 'cvi' + WHEN [d].[Server Name] LIKE 'sun%' OR [d].[Server Name] LIKE 'swsu%' THEN 'sun' + ELSE 'central' + END +ORDER BY CASE + WHEN COUNT(DISTINCT [f].[Server Name]) = 1 THEN 99 + ELSE 2 + END DESC, + MAX([f].[Server Name]) ASC ;