High cpu on sql server box 85-90% utilization

Bob sql 476 Reputation points
2022-05-21T05:14:07.683+00:00

Hi,

Now a days we are receiving high CPU alerts from our monitoring tool. Does seeing High CPU on the box , do we need to do anything/check on the sql server side.

So far, no user complained about slowness of anything of such sort. Any action needs to be taken when we are seeing such alerts?

Thanks,
Bob

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,279 questions
0 comments No comments
{count} votes

Accepted answer
  1. CathyJi-MSFT 22,341 Reputation points Microsoft Vendor
    2022-05-23T06:42:08.65+00:00

    Hi @Bob sql ,

    You can follow the below steps to isolate the problem and mitigate it.
    204526-screenshot-2022-05-23-143730.jpg
    Please refer to below MS document and blog to get detail troubleshooting methods. Such as performance monitor, T-SQL script to get the top queries consuming High CPU, etc.

    Troubleshoot high-CPU-usage issues in SQL Server
    How to troubleshoot high CPU utilization issue in SQL Server?


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Dan Guzman 9,246 Reputation points
    2022-05-21T19:08:42.567+00:00

    So far, no user complained about slowness of anything of such sort. Any action needs to be taken when we are seeing such alerts?

    If all queries are well-tuned, supporting indexes exist, execution plans optimal, and users are happy with existing response time, then CPU utilization reflects percent compute capacity. If the workload increases significantly, response time will degrade and your phone will start ringing.

    A proactive DBA would examine execution plans for efficiency for the most expensive and frequently executed queries for query and index tuning, even if users are not yet complaining.

    2 people found this answer helpful.

  2. Docs 15,551 Reputation points
    2022-05-23T06:54:18.583+00:00

    Cathyji-msft,

    If available please post a link / reference for a Windows PC (Windows 11 or Windows 10).

    In case there is no available link how could the commands in the above link be modified for Windows 11 or Windows 10?

    0 comments No comments

  3. Bob sql 476 Reputation points
    2022-05-24T07:03:49.423+00:00

    1 way of fetching high cpu queries
    -- top 10 queries by worker time

    SELECT TOP 10
    [qs].[last_worker_time],
    [qs].[max_worker_time],
    [qs].[total_worker_time],
    [qs].[execution_count],
    stmt_start = [qs].[statement_start_offset],
    stmt_end = [qs].[statement_end_offset],
    [qt].[dbid],
    [qt].[objectid],
    SUBSTRING([qt].[text], [qs].[statement_start_offset] / 2,
    (CASE WHEN [qs].[statement_end_offset] = -1
    THEN LEN(CONVERT(NVARCHAR(MAX), [qt].[text])) * 2
    ELSE [qs].[statement_end_offset]
    END - [qs].[statement_start_offset]) / 2) AS statement
    FROM [sys].[dm_exec_query_stats] qs
    CROSS APPLY [sys].dm_exec_sql_text AS qt
    ORDER BY [qs].[total_worker_time] DESC; --- i.e. cpu time in microsecs

    Alternate way,

    --- I am grouping the queries by query hash and based on that i am getting total worker time
    SELECT [qs].[last_worker_time],
    [qs].[max_worker_time],
    [qs].[total_worker_time],
    [qs].[execution_count],
    stmt_start = [qs].[statement_start_offset],
    stmt_end = [qs].[statement_end_offset],
    [qt].[dbid],
    [qt].[objectid],
    SUBSTRING([qt].[text], [qs].[statement_start_offset] / 2,
    (CASE WHEN [qs].[statement_end_offset] = -1
    THEN LEN(CONVERT(NVARCHAR(MAX), [qt].[text])) * 2
    ELSE [qs].[statement_end_offset]
    END - [qs].[statement_start_offset]) / 2) AS statement
    FROM [sys].[dm_exec_query_stats] qs
    CROSS APPLY [sys].dm_exec_sql_text AS qt
    ORDER BY [qs].[total_worker_time] DESC;

    -- Plug in query hash
    SELECT SUBSTRING([qt].[text], [qs].[statement_start_offset] / 2,
    (CASE WHEN [qs].[statement_end_offset] = -1
    THEN LEN(CONVERT(NVARCHAR(MAX), [qt].[text])) * 2
    ELSE [qs].[statement_end_offset]
    END - [qs].[statement_start_offset]) / 2) AS statement,
    [qs].[total_worker_time],
    [qs].[execution_count],
    [qs].[query_hash],
    [qs].[query_plan_hash]
    FROM [sys].[dm_exec_query_stats] qs
    CROSS APPLY [sys].dm_exec_sql_text AS qt
    WHERE [qs].[query_hash] = 0x88B8B513764CB9F4C;

    Question here, how can I know in which stored procedure these sql stmts are being used and what parameter values being used at runtime ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.