For those who use MDW and complain about the bug in the report Disk Usage Collection Set - Database, I updated the query so that it shows now the correct data. The bug is very consistent: it's in there from 2008 R2 and still there.
Take a look at the report:
As you can see the report shows more than 8 GB but in the data below you can see that the database size is no more than 4,3 GB.
Someone just made a programming error at Microsoft and unknown on what the field values mean in MDW just mixed up some numbers. I have to admit that it is not easy :-)
I rewrote the query after comparing the values with a real database and added the log value. Now it is to Microsoft to add it.
Here's the code (I highlighted the changes):
I verified it with the real database data and it is 100% correct.
This change wasn't too difficult. Maybe it can be added in a Cummulative Update for SQL Server versions 2008 R2 to 2012.
Take a look at the report:
As you can see the report shows more than 8 GB but in the data below you can see that the database size is no more than 4,3 GB.
Someone just made a programming error at Microsoft and unknown on what the field values mean in MDW just mixed up some numbers. I have to admit that it is not easy :-)
I rewrote the query after comparing the values with a real database and added the log value. Now it is to Microsoft to add it.
Here's the code (I highlighted the changes):
exec sp_executesql @stmt=N'BEGIN TRY
DECLARE @snapshot_id int
SELECT TOP 1 @snapshot_id = snapshot_id
FROM (
SELECT DISTINCT TOP 100 d.snapshot_id
FROM snapshots.disk_usage d,
core.snapshots ss
WHERE ss.instance_name = @ServerName
AND ss.snapshot_id = d.snapshot_id
ORDER BY d.snapshot_id DESC
) AS q
ORDER BY snapshot_id ASC
SELECT
CONVERT (datetime, SWITCHOFFSET
(CAST (d.collection_time AS datetimeoffset), ''+00:00'')) AS collection_time,
d.snapshot_id,
((convert(dec (15,2),d.dbsize) +
convert(dec(15,2),d.logsize)) * 8192 / 1048576.0) AS ''database_size_mb'',
(convert(dec(15,2),d.logsize) * 8192
/ 1048576.0) AS ''log_size_mb'',
((d.usedpages - (d.usedpages -
d.pages)) * 8192 / 1048576.0) AS
''data_size_mb'',
((d.reservedpages - d.usedpages) *
8192 / 1048576.0) AS ''reserved_mb'',
(
case
when d.dbsize >=
d.reservedpages
then (convert (dec
(15,2),d.dbsize) - convert (dec (15,2),d.reservedpages)) * 8192 /
1048576.0
else 0
end) AS
''unallocated_space_mb'',
((d.usedpages - d.pages) * 8192 /
1048576.0) AS ''index_mb''
FROM snapshots.disk_usage d,
core.snapshots ss
WHERE database_name=@SelectedDatabaseName
AND d.snapshot_id >= @snapshot_id
AND ss.instance_name = @ServerName
AND d.snapshot_id = ss.snapshot_id
ORDER BY collection_time
END TRY
BEGIN CATCH
SELECT
null AS collection_time,
ERROR_NUMBER() AS snapshot_id,
ERROR_SEVERITY() AS database_size_mb,
ERROR_STATE() AS reserved_mb,
ERROR_MESSAGE() AS unallocated_space_mb,
1 AS index_mb
END CATCH',@params=N'@ServerName NVarChar(max),
@SelectedDatabaseName NVarChar(max)',@ServerName=N'MyServer',@SelectedDatabaseName=N'MDW'
I verified it with the real database data and it is 100% correct.
This change wasn't too difficult. Maybe it can be added in a Cummulative Update for SQL Server versions 2008 R2 to 2012.
Comments
Post a Comment