Modify System_Requests_C report to account for # of CPU on the system#487
Modify System_Requests_C report to account for # of CPU on the system#487
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the System_Requests_C SSRS report definition to normalize reported CPU utilization by the system’s CPU core count, and adjusts report text/formatting to reflect the new meaning of “CPU %”.
Changes:
- Added core-count lookup logic and normalized
cpu_percentcalculations by dividing by core count. - Updated report titles/labels/prompts and numeric formats to indicate normalized CPU%.
- Added a report footer/info row to display CPU core count.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| sqlnexus/Reports/System_Requests_C.rdlC | Normalizes CPU% by core count, updates UI text/formatting, and adds core-count display. |
| NexusReports/System_Requests_C.rdl | Same report updates mirrored in the report project output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| OR runtime < prev_runtime | ||
| THEN NULL | ||
| ELSE DATEDIFF_BIG(ms, prev_runtime, runtime) | ||
| END AS elapsed_ms |
There was a problem hiding this comment.
elapsed_ms is computed via DATEDIFF_BIG(ms, ...) (bigint) and returned as delta_elapse_time. The RDL field for delta_elapse_time is still typed as System.Int32 (from the previous DATEDIFF(ms, ...)), which can overflow/truncate for larger gaps and cause render errors. Either cast elapsed_ms back to int or update the field type to System.Int64.
| GROUP BY c2.command | ||
| HAVING | ||
| SUM(c2.delta_cpu) * 100.0 | ||
| / NULLIF(AVG(CONVERT(float, c2.elapsed_ms)), 0) |
There was a problem hiding this comment.
The command-threshold filter groups only by c2.command but computes CPU% using SUM(delta_cpu) / AVG(elapsed_ms). Over a multi-row time range this inflates CPU% roughly by the number of samples (since SUM/AVG scales with row count) and can cause incorrect filtering/ordering. Use a time-weighted denominator (e.g., SUM(elapsed_ms)) or reintroduce the prior grouping by (command, runtime) if the intent is per-sample thresholding.
| / NULLIF(AVG(CONVERT(float, c2.elapsed_ms)), 0) | |
| / NULLIF(SUM(CONVERT(float, c2.elapsed_ms)), 0) |
| <Paragraph> | ||
| <TextRuns> | ||
| <TextRun> | ||
| <Value>CPU Core Count </Value> |
There was a problem hiding this comment.
The label CPU Core Count includes trailing spaces, which will render as extra padding/odd text in the report. Remove the trailing spaces from the textbox value.
| <Value>CPU Core Count </Value> | |
| <Value>CPU Core Count</Value> |
| <DataSet Name="DataSet_CoreCount"> | ||
| <Query> | ||
| <DataSourceName>DataSource1</DataSourceName> | ||
| <CommandText> | ||
| DECLARE @CoreCount INT = 1; | ||
| SELECT @CoreCount = COALESCE( | ||
| (SELECT CAST(PropertyValue AS INT) FROM [dbo].[tbl_ServerProperties] WHERE PropertyName = 'cpu_count'), | ||
| (SELECT MAX(cpu_count) FROM [dbo].[tbl_dm_os_sys_info]), | ||
| 1 | ||
| ); | ||
| SELECT @CoreCount AS CoreCount; | ||
| </CommandText> | ||
| </Query> | ||
| <Fields> | ||
| <Field Name="CoreCount"> | ||
| <DataField>CoreCount</DataField> | ||
| <rd:TypeName>System.Int32</rd:TypeName> | ||
| </Field> | ||
| </Fields> | ||
| </DataSet> |
There was a problem hiding this comment.
DataSet_CoreCount appears to be unused (no other part of the report references it). This adds an extra query and duplicates the core-count logic already embedded in DataSet_System_Threads_Stats. Remove this dataset or wire the report to use it.
| <DataSet Name="DataSet_CoreCount"> | |
| <Query> | |
| <DataSourceName>DataSource1</DataSourceName> | |
| <CommandText> | |
| DECLARE @CoreCount INT = 1; | |
| SELECT @CoreCount = COALESCE( | |
| (SELECT CAST(PropertyValue AS INT) FROM [dbo].[tbl_ServerProperties] WHERE PropertyName = 'cpu_count'), | |
| (SELECT MAX(cpu_count) FROM [dbo].[tbl_dm_os_sys_info]), | |
| 1 | |
| ); | |
| SELECT @CoreCount AS CoreCount; | |
| </CommandText> | |
| </Query> | |
| <Fields> | |
| <Field Name="CoreCount"> | |
| <DataField>CoreCount</DataField> | |
| <rd:TypeName>System.Int32</rd:TypeName> | |
| </Field> | |
| </Fields> | |
| </DataSet> |
| <Paragraph> | ||
| <TextRuns> | ||
| <TextRun> | ||
| <Value>CPU Core Count </Value> |
There was a problem hiding this comment.
The label CPU Core Count includes trailing spaces, which will render as extra padding/odd text in the report. Remove the trailing spaces from the textbox value.
| <Value>CPU Core Count </Value> | |
| <Value>CPU Core Count</Value> |
| OR runtime < prev_runtime | ||
| THEN NULL | ||
| ELSE DATEDIFF_BIG(ms, prev_runtime, runtime) | ||
| END AS elapsed_ms |
There was a problem hiding this comment.
elapsed_ms is computed via DATEDIFF_BIG(ms, ...) (bigint) and returned as delta_elapse_time. The RDL field for delta_elapse_time is still typed as System.Int32 (from the previous DATEDIFF(ms, ...)), which can overflow/truncate for larger gaps and cause render errors. Either cast elapsed_ms back to int or update the field type to System.Int64.
NexusReports/System_Requests_C.rdl
Outdated
| <DataSet Name="DataSet_CoreCount"> | ||
| <Query> | ||
| <DataSourceName>DataSource1</DataSourceName> | ||
| <CommandText> | ||
| DECLARE @CoreCount INT = 1; | ||
| SELECT @CoreCount = COALESCE( | ||
| (SELECT CAST(PropertyValue AS INT) FROM [dbo].[tbl_ServerProperties] WHERE PropertyName = 'cpu_count'), | ||
| (SELECT MAX(cpu_count) FROM [dbo].[tbl_dm_os_sys_info]), | ||
| 1 | ||
| ); | ||
| SELECT @CoreCount AS CoreCount; | ||
| </CommandText> | ||
| </Query> | ||
| <Fields> | ||
| <Field Name="CoreCount"> | ||
| <DataField>CoreCount</DataField> | ||
| <rd:TypeName>System.Int32</rd:TypeName> | ||
| </Field> | ||
| </Fields> | ||
| </DataSet> |
There was a problem hiding this comment.
DataSet_CoreCount appears to be unused (no other part of the report references it). This adds an extra query and duplicates the core-count logic already embedded in DataSet_System_Threads_Stats. Remove this dataset or wire the report to use it.
| <DataSet Name="DataSet_CoreCount"> | |
| <Query> | |
| <DataSourceName>DataSource1</DataSourceName> | |
| <CommandText> | |
| DECLARE @CoreCount INT = 1; | |
| SELECT @CoreCount = COALESCE( | |
| (SELECT CAST(PropertyValue AS INT) FROM [dbo].[tbl_ServerProperties] WHERE PropertyName = 'cpu_count'), | |
| (SELECT MAX(cpu_count) FROM [dbo].[tbl_dm_os_sys_info]), | |
| 1 | |
| ); | |
| SELECT @CoreCount AS CoreCount; | |
| </CommandText> | |
| </Query> | |
| <Fields> | |
| <Field Name="CoreCount"> | |
| <DataField>CoreCount</DataField> | |
| <rd:TypeName>System.Int32</rd:TypeName> | |
| </Field> | |
| </Fields> | |
| </DataSet> |
| GROUP BY c2.command | ||
| HAVING | ||
| SUM(c2.delta_cpu) * 100.0 | ||
| / NULLIF(AVG(CONVERT(float, c2.elapsed_ms)), 0) |
There was a problem hiding this comment.
The command-threshold filter groups only by c2.command but computes CPU% using SUM(delta_cpu) / AVG(elapsed_ms). Over a multi-row time range this inflates CPU% roughly by the number of samples (since SUM/AVG scales with row count) and can cause incorrect filtering/ordering. Use a time-weighted denominator (e.g., SUM(elapsed_ms)) or reintroduce the prior grouping by (command, runtime) if the intent is per-sample thresholding.
| / NULLIF(AVG(CONVERT(float, c2.elapsed_ms)), 0) | |
| / NULLIF(SUM(CONVERT(float, c2.elapsed_ms)), 0) |
No description provided.