Skip to content

Conversation

@DavidWiseman
Copy link
Collaborator

Add option to collect top 3 waits from sys.dm_os_waiting_tasks. #1632
Collect DOP. #1630

Copilot AI review requested due to automatic review settings November 12, 2025 09:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to collect the degree of parallelism (DOP) and provides an option to collect task-level waits from sys.dm_os_waiting_tasks for running queries.

Key Changes:

  • Added CollectTaskWaits configuration option to enable collecting top 3 task waits
  • Introduced new database columns for storing task wait information (type and time for top 3 waits) and DOP
  • Updated UI to include task waits and DOP display in the running queries view

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
DBADashServiceConfig/ServiceConfig.resx Reorganized resource file entries (no functional changes)
DBADashServiceConfig/ServiceConfig.cs Added UI controls and configuration for CollectTaskWaits option
DBADashGUI/Performance/RunningQueries.cs Added DOP and TaskWaits columns to the running queries grid display
DBADashDB/dbo/Views/RunningQueriesInfo.sql Added task wait concatenation logic and DOP column to view
DBADashDB/dbo/User Defined Types/RunningQueries.sql Added columns for task wait types/times and DOP
DBADashDB/dbo/Tables/RunningQueries.sql Added storage columns for task waits and DOP
DBADashDB/dbo/Stored Procedures/RunningQueries_Upd.sql Updated insert statements to include new task wait and DOP columns
DBADashDB/dbo/Stored Procedures/RunningQueries_Get.sql Added TaskWaits and DOP to result set
DBADashDB/dbo/Stored Procedures/RunningQueriesForSession_Get.sql Added TaskWaits and DOP to session queries result set
DBADashDB/dbo/Stored Procedures/RunningQueriesForJob_Get.sql Added TaskWaits and DOP to job queries result set
DBADashConfig/Options.cs Added CollectTaskWaits command-line option
DBADashConfig/Helper.cs Added CollectTaskWaits to configuration helper
DBADash/SQL/SQLRunningQueries.sql Added SQL logic to collect top 3 task waits and DOP from DMVs
DBADash/DBImporter.cs Added backward compatibility for new columns in data import
DBADash/DBCollector.cs Passed CollectTaskWaits parameter to collection query
DBADash/DBADashSource.cs Added CollectTaskWaits property to source configuration
DBADash.Test/DBADashConfig.cs Updated test to include CollectTaskWaits parameter
Files not reviewed (1)
  • DBADashServiceConfig/ServiceConfig.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +98
CONCAT(Q.task_wait_type_1 + ' (' + CAST(Q.task_wait_time_1 AS NVARCHAR(260)) + 'ms)',
', ' + Q.task_wait_type_2 + ' (' + CAST(Q.task_wait_time_2 AS NVARCHAR(260)) + 'ms)',
', ' + Q.task_wait_type_3 + ' (' + CAST(Q.task_wait_time_3 AS NVARCHAR(260)) + 'ms)') AS TaskWaits,
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the + operator for string concatenation with NULL values will result in NULL for the entire expression. When any of the task_wait_type columns are NULL (which they will be when fewer than 3 wait types exist), the entire TaskWaits result will be NULL. Use CONCAT() properly without the + operators, or handle NULLs explicitly with ISNULL() or COALESCE().

Suggested change
CONCAT(Q.task_wait_type_1 + ' (' + CAST(Q.task_wait_time_1 AS NVARCHAR(260)) + 'ms)',
', ' + Q.task_wait_type_2 + ' (' + CAST(Q.task_wait_time_2 AS NVARCHAR(260)) + 'ms)',
', ' + Q.task_wait_type_3 + ' (' + CAST(Q.task_wait_time_3 AS NVARCHAR(260)) + 'ms)') AS TaskWaits,
CONCAT(
Q.task_wait_type_1, ' (', CAST(Q.task_wait_time_1 AS NVARCHAR(260)), 'ms)',
', ', Q.task_wait_type_2, ' (', CAST(Q.task_wait_time_2 AS NVARCHAR(260)), 'ms)',
', ', Q.task_wait_type_3, ' (', CAST(Q.task_wait_time_3 AS NVARCHAR(260)), 'ms)'
) AS TaskWaits,

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. It's desirable for the expressions concatenated with + to return NULL as each represent an expression for one of the top 3 wait types. Each of these 3 expressions are concatenated with CONCAT which doesn't result in a NULL value. e.g.

If any part of this is NULL, it should be NULL

Q.task_wait_type_1 + ' (' + CAST(Q.task_wait_time_1 AS NVARCHAR(260)) + 'ms)'

Same here:

', ' + Q.task_wait_type_2 + ' (' + CAST(Q.task_wait_time_2 AS NVARCHAR(260)) + 'ms)'

and here:

', ' + Q.task_wait_type_3 + ' (' + CAST(Q.task_wait_time_3 AS NVARCHAR(260)) + 'ms)')

But these are combined with CONCAT so we don't get NULL if we don't have 3 task waits.

@DavidWiseman DavidWiseman merged commit 20115d5 into trimble-oss:main Nov 12, 2025
@DavidWiseman DavidWiseman deleted the 1632_RunningQueries-TaskWait branch November 12, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant