Пришлось не так давно выяснять, почему база в которой и данных то почти нет, съела 250Гб...
Выяснили с помощью вот этого скрипта.
SELECT
[o].[id]
, OBJECT_NAME([o].[id], DB_ID()) AS [table_name]
, [i1].[rowcnt] AS [rows]
, (ISNULL(SUM([i1].[reserved]), 0) + ISNULL(SUM([i2].[reserved]), 0)) * [ps].[pagesizeKB] AS [reservedKB]
, (ISNULL(SUM([i1].[dpages]), 0) + ISNULL(SUM([i2].[used]), 0)) * [ps].[pagesizeKB] AS [dataKB]
, ((ISNULL(SUM([i1].[used]), 0) + ISNULL(SUM([i2].[used]), 0))
- (ISNULL(SUM([i1].[dpages]), 0) + ISNULL(SUM([i2].[used]), 0))) * [ps].[pagesizeKB] AS [index_sizeKB]
, ((ISNULL(SUM([i1].[reserved]), 0) + ISNULL(SUM([i2].[reserved]), 0))
- (ISNULL(SUM([i1].[used]), 0) + ISNULL(SUM([i2].[used]), 0))) * [ps].[pagesizeKB] AS [unusedKB]
FROM [sys].[sysobjects] [o]
LEFT OUTER JOIN [sys].[sysindexes] [i1] ON [i1].[id] = [o].[id] AND [i1].[indid] < 2
LEFT OUTER JOIN [sys].[sysindexes] [i2] ON [i2].[id] = [o].[id] AND [i2].[indid] = 255
CROSS JOIN (SELECT ([low] / 1024) [pagesizeKB] FROM [master].[dbo].[spt_values] WHERE [number] = 1 AND [type] = 'E' ) AS [ps]
WHERE OBJECTPROPERTY([o].[id], N'IsUserTable') = 1 --same as: [o].xtype = 'IsView'
OR (OBJECTPROPERTY([o].[id], N'IsView') = 1 AND OBJECTPROPERTY([o].[id], N'IsIndexed') = 1)
GROUP BY [ps].[pagesizeKB], [o].[id], [i1].[rowcnt]
ORDER BY 3 DESC
Комментариев нет:
Отправить комментарий