Updated sqlserver.go - Added Rows/Logs max size (#1380)
I added Rows/Logs max size counters for tracking databases that do not have autogrowth enabled. The counters return numbers in 8KB pages since there are a few special values (such as -1 for no max size) that can't directly be multiplied by 8192 to get size in bytes. Also added Rows/Logs size in 8KB pages for comparison from the same system table. Even though it returns the same size as sizes from sys.dm_io_virtual_file_stats which are already collected.
This commit is contained in:
parent
2beef21231
commit
4b6f9b93dd
|
@ -400,6 +400,8 @@ IF OBJECT_ID('tempdb..#baseline') IS NOT NULL
|
|||
DROP TABLE #baseline;
|
||||
SELECT
|
||||
DB_NAME(mf.database_id) AS database_name ,
|
||||
mf.size as database_size_8k_pages,
|
||||
mf.max_size as database_max_size_8k_pages,
|
||||
size_on_disk_bytes ,
|
||||
type_desc as datafile_type,
|
||||
GETDATE() AS baselineDate
|
||||
|
@ -435,6 +437,50 @@ FROM #baseline
|
|||
WHERE datafile_type = ''ROWS''
|
||||
) as V
|
||||
PIVOT(SUM(size_on_disk_bytes) FOR database_name IN (' + @ColumnName + ')) AS PVTTable
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT measurement = ''Rows size (8KB pages)'', servername = REPLACE(@@SERVERNAME, ''\'', '':''), type = ''Database size''
|
||||
, ' + @ColumnName + ' FROM
|
||||
(
|
||||
SELECT database_name, database_size_8k_pages
|
||||
FROM #baseline
|
||||
WHERE datafile_type = ''ROWS''
|
||||
) as V
|
||||
PIVOT(SUM(database_size_8k_pages) FOR database_name IN (' + @ColumnName + ')) AS PVTTable
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT measurement = ''Log size (8KB pages)'', servername = REPLACE(@@SERVERNAME, ''\'', '':''), type = ''Database size''
|
||||
, ' + @ColumnName + ' FROM
|
||||
(
|
||||
SELECT database_name, database_size_8k_pages
|
||||
FROM #baseline
|
||||
WHERE datafile_type = ''LOG''
|
||||
) as V
|
||||
PIVOT(SUM(database_size_8k_pages) FOR database_name IN (' + @ColumnName + ')) AS PVTTable
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT measurement = ''Rows max size (8KB pages)'', servername = REPLACE(@@SERVERNAME, ''\'', '':''), type = ''Database size''
|
||||
, ' + @ColumnName + ' FROM
|
||||
(
|
||||
SELECT database_name, database_max_size_8k_pages
|
||||
FROM #baseline
|
||||
WHERE datafile_type = ''ROWS''
|
||||
) as V
|
||||
PIVOT(SUM(database_max_size_8k_pages) FOR database_name IN (' + @ColumnName + ')) AS PVTTable
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT measurement = ''Logs max size (8KB pages)'', servername = REPLACE(@@SERVERNAME, ''\'', '':''), type = ''Database size''
|
||||
, ' + @ColumnName + ' FROM
|
||||
(
|
||||
SELECT database_name, database_max_size_8k_pages
|
||||
FROM #baseline
|
||||
WHERE datafile_type = ''LOG''
|
||||
) as V
|
||||
PIVOT(SUM(database_max_size_8k_pages) FOR database_name IN (' + @ColumnName + ')) AS PVTTable
|
||||
'
|
||||
--PRINT @DynamicPivotQuery
|
||||
EXEC sp_executesql @DynamicPivotQuery;
|
||||
|
|
Loading…
Reference in New Issue