Skip to content

Commit

Permalink
performance improvements, formatting, and authorship
Browse files Browse the repository at this point in the history
  • Loading branch information
EitanBlumin committed Sep 10, 2021
1 parent f897c32 commit 291c1fd
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down Expand Up @@ -40,27 +41,28 @@ SELECT
, file_total_reserved_pages
, prev_used_page
, from_used_page_id = allocated_page_page_id
, to_page_id = ISNULL(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page)
, consecutive_unused_pages = ISNULL(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page) - allocated_page_page_id
, to_page_id = COALESCE(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page, file_total_size-1)
, consecutive_unused_pages = COALESCE(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page, file_total_size-1) - allocated_page_page_id
, next_used_page_id = LEAD(allocated_page_page_id,1,file_total_size-1) OVER(PARTITION BY file_id ORDER BY allocated_page_page_id ASC)
FROM
(
SELECT
f.database_id, f.file_id, f.file_name, f.file_total_used_space, f.file_total_size
p.allocated_page_file_id
, file_total_reserved_pages = COUNT(*) OVER() + 9
, p.allocated_page_page_id
, prev_used_page = LAG(p.allocated_page_page_id,1,0) OVER (PARTITION BY f.file_id ORDER BY p.allocated_page_page_id ASC)
, next_used_page = LEAD(p.allocated_page_page_id,1,f.file_total_size - 1) OVER (PARTITION BY f.file_id ORDER BY p.allocated_page_page_id ASC)
FROM (
, prev_used_page = LAG(p.allocated_page_page_id,1,0) OVER (PARTITION BY p.allocated_page_file_id ORDER BY p.allocated_page_page_id ASC)
, next_used_page = LEAD(p.allocated_page_page_id,1, NULL) OVER (PARTITION BY p.allocated_page_file_id ORDER BY p.allocated_page_page_id ASC)
FROM sys.dm_db_database_page_allocations(DB_ID(),default,default,default,'DETAILED') AS p
) AS sub1
INNER JOIN
(
SELECT database_id, file_id, file_name = [name], size AS file_total_size
, file_total_used_space = FILEPROPERTY([name], 'SpaceUsed')
FROM sys.master_files AS f
WHERE database_id = DB_ID() AND type = 0
) AS f
INNER JOIN sys.dm_db_database_page_allocations(DB_ID(),default,default,default,'DETAILED') AS p
ON f.file_id = p.allocated_page_file_id
) AS sub1
WHERE sub1.next_used_page &lt;&gt; sub1.allocated_page_page_id + 1
ON f.file_id = sub1.allocated_page_file_id
WHERE ISNULL(sub1.next_used_page, f.file_total_size - 1) &lt;&gt; sub1.allocated_page_page_id + 1
) AS sub2
CROSS APPLY
(
Expand Down Expand Up @@ -396,10 +398,9 @@ CROSS APPLY
<Y>=Sum(Fields!pages_in_range.Value) / 128.0</Y>
</ChartDataPointValues>
<ChartDataLabel>
<Style>
<Format>#,0 MB</Format>
</Style>
<UseValueAsLabel>true</UseValueAsLabel>
<Style />
<Label>=IIF(Sum(Fields!pages_in_range.Value) / 128 &gt;= 1,
Format(Sum(Fields!pages_in_range.Value) / 128.0, "#,0 MB"), "")</Label>
<Visible>true</Visible>
</ChartDataLabel>
<ToolTip>=" From page: " &amp; Min(Fields!from_page_id.Value) &amp; vbCrLf &amp; ", To page: " &amp; Max(Fields!to_page_id.Value) &amp; vbCrLf &amp; ", Total Pages: " &amp; Sum(Fields!pages_in_range.Value) &amp; vbCrLf &amp; ", Size: " &amp; (CDec(Sum(Fields!pages_in_range.Value)) / 128.0) &amp; " MB"</ToolTip>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down Expand Up @@ -40,27 +41,28 @@ SELECT
, file_total_reserved_pages
, prev_used_page
, from_used_page_id = allocated_page_page_id
, to_page_id = ISNULL(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page)
, consecutive_unused_pages = ISNULL(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page) - allocated_page_page_id
, to_page_id = COALESCE(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page, f.file_total_size - 1)
, consecutive_unused_pages = COALESCE(NULLIF(next_used_page,file_total_size-1) - 1, next_used_page, f.file_total_size - 1) - allocated_page_page_id
, next_used_page_id = LEAD(allocated_page_page_id,1,file_total_size-1) OVER(PARTITION BY file_id ORDER BY allocated_page_page_id ASC)
FROM
(
SELECT
f.database_id, f.file_id, f.file_name, f.file_total_used_space, f.file_total_size
p.allocated_page_file_id
, file_total_reserved_pages = COUNT(*) OVER() + 9
, p.allocated_page_page_id
, prev_used_page = LAG(p.allocated_page_page_id,1,0) OVER (PARTITION BY f.file_id ORDER BY p.allocated_page_page_id ASC)
, next_used_page = LEAD(p.allocated_page_page_id,1,f.file_total_size - 1) OVER (PARTITION BY f.file_id ORDER BY p.allocated_page_page_id ASC)
FROM (
, prev_used_page = LAG(p.allocated_page_page_id,1,0) OVER (PARTITION BY p.allocated_page_file_id ORDER BY p.allocated_page_page_id ASC)
, next_used_page = LEAD(p.allocated_page_page_id,1, NULL) OVER (PARTITION BY p.allocated_page_file_id ORDER BY p.allocated_page_page_id ASC)
FROM sys.dm_db_database_page_allocations(DB_ID(),default,default,default,'DETAILED') AS p
) AS sub1
INNER JOIN
(
SELECT database_id, file_id, file_name = [name], size AS file_total_size
, file_total_used_space = FILEPROPERTY([name], 'SpaceUsed')
FROM sys.master_files AS f
WHERE database_id = DB_ID() AND type = 0
) AS f
INNER JOIN sys.dm_db_database_page_allocations(DB_ID(),default,default,default,'DETAILED') AS p
ON f.file_id = p.allocated_page_file_id
) AS sub1
WHERE sub1.next_used_page &lt;&gt; sub1.allocated_page_page_id + 1
ON f.file_id = sub1.allocated_page_file_id
WHERE ISNULL(sub1.next_used_page, f.file_total_size - 1) &lt;&gt; sub1.allocated_page_page_id + 1
) AS sub2
CROSS APPLY
(
Expand Down Expand Up @@ -396,10 +398,9 @@ CROSS APPLY
<Y>=Sum(Fields!pages_in_range.Value) / 128.0</Y>
</ChartDataPointValues>
<ChartDataLabel>
<Style>
<Format>#,0 MB</Format>
</Style>
<UseValueAsLabel>true</UseValueAsLabel>
<Style />
<Label>=IIF(Sum(Fields!pages_in_range.Value) / 128 &gt;= 1,
Format(Sum(Fields!pages_in_range.Value) / 128.0, "#,0 MB"), "")</Label>
<Visible>true</Visible>
</ChartDataLabel>
<ToolTip>=" From page: " &amp; Min(Fields!from_page_id.Value) &amp; vbCrLf &amp; ", To page: " &amp; Max(Fields!to_page_id.Value) &amp; vbCrLf &amp; ", Total Pages: " &amp; Sum(Fields!pages_in_range.Value) &amp; vbCrLf &amp; ", Size: " &amp; (CDec(Sum(Fields!pages_in_range.Value)) / 128.0) &amp; " MB"</ToolTip>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down Expand Up @@ -360,7 +361,9 @@ INNER JOIN sys.database_files AS df ON df.file_id = li.FileID</CommandText>
<Y>=Sum(Fields!vlf_size_mb.Value)</Y>
</ChartDataPointValues>
<ChartDataLabel>
<Style />
<Style>
<Format>#,0 MB</Format>
</Style>
<UseValueAsLabel>true</UseValueAsLabel>
<Visible>true</Visible>
</ChartDataLabel>
Expand Down Expand Up @@ -662,7 +665,7 @@ INNER JOIN sys.database_files AS df ON df.file_id = li.FileID</CommandText>
</Style>
</ChartNoDataMessage>
<DataSetName>TranLogAllocation</DataSetName>
<Top>1.2cm</Top>
<Top>1.16445cm</Top>
<Height>13.25182cm</Height>
<Width>29.35141cm</Width>
<Style>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<Author>Eitan Blumin</Author>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="LocalServer">
Expand Down Expand Up @@ -341,7 +342,9 @@ FROM sys.dm_db_log_info(DB_ID())</CommandText>
<Y>=Sum(Fields!vlf_size_mb.Value)</Y>
</ChartDataPointValues>
<ChartDataLabel>
<Style />
<Style>
<Format>#,0 MB</Format>
</Style>
<UseValueAsLabel>true</UseValueAsLabel>
<Visible>true</Visible>
</ChartDataLabel>
Expand Down

0 comments on commit 291c1fd

Please sign in to comment.