JusDB
Free DB Audit
Database Performance

SQL Server High CPU Usage: Find the Query and Fix the Cause

Confirm sqlservr is using the CPU, find the top CPU queries live and in Query Store, then fix plan regressions, stale statistics, missing indexes and parallelism.

JusDB Team
Published September 22, 2026
21 min read

The alert says the database server is at 95% CPU, the application is timing out, and someone suggests adding cores. Before anyone resizes anything, answer three questions: is sqlservr the process using the CPU, which queries are using it right now, and which used it over the last day. This guide answers them in that order for SQL Server 2019, 2022, and 2025, and Azure SQL Database, following Microsoft's troubleshoot high CPU usage in SQL Server procedure. It then covers the signals that pick the fix: SOS_SCHEDULER_YIELD and parallelism waits, MAXDOP, plan regressions in Query Store, implicit conversions, missing indexes, and stale statistics.

TL;DR
  • Confirm the consumer first: the RING_BUFFER_SCHEDULER_MONITOR records in sys.dm_os_ring_buffers split CPU into SQL Server, other processes, and idle. If SQL Server is not the main consumer, query tuning will not help.
  • For a live incident, sort sys.dm_exec_requests by cpu_time and pull the statement text. For history, use sys.dm_exec_query_stats or Query Store's Top Resource Consuming Queries sorted by CPU time.
  • Microsoft's common causes are stale statistics, missing indexes, parameter sensitive plans, poorly designed queries, and workload growth. Check them before server settings.
  • A plan that regressed can be pinned with sp_query_store_force_plan as a stopgap. SQL Server 2022 at compatibility level 160 adds parameter sensitive plan (PSP) optimization, and SQL Server 2025 at level 170 extends it to DML.
  • Change MAXDOP or cost threshold for parallelism only when parallelism waits dominate, in small steps.

Scope and review date: November 2026. This post covers SQL Server 2019, 2022, and 2025 on Windows and Linux, plus Azure SQL Database and Azure SQL Managed Instance where noted. Queries, defaults, and version details were checked against Microsoft Learn on 25 November 2026. They were not run in a lab, so test them on a non-production instance before you depend on them during an incident.


How do I confirm SQL Server is the process using the CPU?

Step 1 of Microsoft's high CPU article checks the Process(sqlservr)\% User Time and % Privileged Time counters. If privileged time is consistently above 90 percent, Microsoft points at antivirus, drivers, or another operating system component, not at your queries.

From inside SQL Server, the scheduler monitor ring buffer gives the same split without remote access to the host. The query below is adapted from Microsoft's SQL Server blog post on CPU usage in sys.dm_os_ring_buffers, with a wall-clock time added from sys.dm_os_sys_info.ms_ticks.

sql
DECLARE @ms_now bigint = (SELECT ms_ticks FROM sys.dm_os_sys_info);

SELECT TOP (30)
    DATEADD(ms, -1 * (@ms_now - rb.[timestamp]), GETDATE()) AS sample_time,
    rb.record_xml.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_pct,
    rb.record_xml.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS idle_pct,
    100 - rb.record_xml.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int')
        - rb.record_xml.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS other_cpu_pct
FROM (
    SELECT [timestamp], CONVERT(xml, record) AS record_xml
    FROM sys.dm_os_ring_buffers
    WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR'
      AND record LIKE N'%<SystemHealth>%'
) AS rb
ORDER BY rb.[timestamp] DESC;

Interpretation: sql_cpu_pct is the SQL Server process, idle_pct is the idle share, and other_cpu_pct is everything else on the host. A high sql_cpu_pct sends you to the query steps below. A high other_cpu_pct sends you to the operating system. On Linux, Microsoft notes that SystemIdle is reported as 0, so read only the SQL Server column there.

Scheduler monitor samples during a CPU incident

Illustrative output: the shape of the ring buffer query result, not measured data

sqlcmd: SQL Server 2022 on Windows
1> :r ring_buffer_cpu.sql2> GOsample_time sql_cpu_pct idle_pct other_cpu_pct------------------- ----------- -------- -------------2026-09-21 10:42:11 94 3 32026-09-21 10:41:11 92 4 42026-09-21 10:40:11 88 8 42026-09-21 10:39:11 41 55 42026-09-21 10:38:11 38 58 4

Read it as: SQL Server owns the CPU and the jump started between two samples, which gives you the time window to search in Query Store. The record format is documented as informational only in the sys.dm_os_ring_buffers reference.

Treat the ring buffer as a trend, not a meter

Some readers of Microsoft's post report values that differ from Task Manager on Windows hosts. Use it to see when CPU jumped and who owned it, then confirm with Performance Monitor.

Which queries are using the CPU right now?

If the incident is still running, the answer is in sys.dm_exec_requests. Microsoft's step 2 also includes a five-second sampling query that shows what share of total CPU capacity the running requests used; if that share is low while the host is busy, the cause is short, frequent queries, so go straight to the historical views in the next section.

List the requests, heaviest first, with the statement running inside each batch:

sql
SELECT TOP (10)
    r.session_id, r.status, r.cpu_time, r.logical_reads, r.dop,
    r.total_elapsed_time / 1000 AS elapsed_s,
    SUBSTRING(st.text, (r.statement_start_offset / 2) + 1,
        ((CASE r.statement_end_offset WHEN -1 THEN DATALENGTH(st.text)
          ELSE r.statement_end_offset END - r.statement_start_offset) / 2) + 1) AS statement_text,
    s.login_name, s.host_name, s.program_name,
    r.plan_handle, r.query_hash
FROM sys.dm_exec_requests AS r
JOIN sys.dm_exec_sessions AS s ON s.session_id = r.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS st
WHERE r.session_id <> @@SPID
ORDER BY r.cpu_time DESC;

Interpretation: cpu_time is in milliseconds and can exceed elapsed time when dop is above 1, because parallel workers add their CPU together. Keep query_hash: it groups the same statement with different literal values, and you will search Query Store for it later. The Azure SQL high CPU guide adds the in-flight plan from sys.dm_exec_query_statistics_xml.

Is the CPU queue backing up?

sql
SELECT scheduler_id, cpu_id, current_tasks_count,
       runnable_tasks_count, work_queue_count
FROM sys.dm_os_schedulers
WHERE scheduler_id < 1048576
ORDER BY runnable_tasks_count DESC;

Interpretation: per the sys.dm_os_schedulers reference, runnable_tasks_count above 0 means workers are ready to run but waiting for a CPU, and work_queue_count above 0 means tasks are waiting for a worker thread. Sustained runnable queues on most schedulers are what CPU pressure looks like from inside SQL Server.

Which queries used the most CPU over the last day?

Many CPU incidents come from thousands of short executions, not one long query, and those never sit at the top of sys.dm_exec_requests. Microsoft's step 2 ranks sys.dm_exec_query_stats by total_worker_time (microseconds), but the plan cache forgets everything on a restart, a cache flush, or memory pressure. Query Store keeps the history.

Starting with SQL Server 2022 it is on by default for new databases. On SQL Server 2019, check sys.database_query_store_options before you rely on it. The query below is Microsoft's Azure SQL "top 15 queries by CPU" query; it also works on SQL Server 2019 and later.

sql
WITH AggregatedCPU AS (
    SELECT q.query_hash,
        SUM(rs.count_executions * rs.avg_cpu_time / 1000.0) AS total_cpu_ms,
        COUNT(DISTINCT p.plan_id) AS number_of_distinct_plans,
        COUNT(DISTINCT p.query_id) AS number_of_distinct_query_ids,
        SUM(rs.count_executions) AS total_executions,
        MIN(qt.query_sql_text) AS sampled_query_text
    FROM sys.query_store_query_text AS qt
    JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id
    JOIN sys.query_store_plan AS p ON q.query_id = p.query_id
    JOIN sys.query_store_runtime_stats AS rs ON rs.plan_id = p.plan_id
    JOIN sys.query_store_runtime_stats_interval AS rsi
        ON rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id
    WHERE rs.execution_type_desc IN ('Regular', 'Aborted', 'Exception')
      AND rsi.start_time >= DATEADD(HOUR, -2, GETUTCDATE())
    GROUP BY q.query_hash)
SELECT TOP (15) *
FROM AggregatedCPU
ORDER BY total_cpu_ms DESC;

Interpretation: widen -2 to cover the window the ring buffer showed. A high number_of_distinct_plans for one hash is a plan-choice problem (next sections). A high number_of_distinct_query_ids means the application sends the same statement with literal values, so it compiles again and again; Microsoft's guide recommends parameterizing those statements.

In SSMS, open Top Resource Consuming Queries under the database's Query Store node and switch the metric from Duration to CPU Time (ms); the default duration view hides parallel queries whose CPU time is far above their duration.

The triage order for high CPU in SQL Server

Confirm the consumer, find the statements, then fix and re-measure

High CPU triage order Step 1: confirm with the scheduler monitor ring buffer and Performance Monitor that sqlservr is the process using the CPU. Step 2: find the statements, using sys.dm_exec_requests for running queries and sys.dm_exec_query_stats or Query Store for history. Step 3: fix the cause, such as statistics, a missing index, a regressed plan or parallelism settings, then return to step 1 and measure again. Confirm sqlservr share Find live and history Fix one change 1 ring buffer, perfmon 2 requests, Query Store 3 measure again after every change

Why the order matters: skipping step 1 is how teams tune queries for a week while antivirus or a backup agent on the host was using the CPU.

What do SOS_SCHEDULER_YIELD and CXPACKET waits tell me?

Waits do not show CPU directly, but two families point at it. The sys.dm_os_wait_stats reference describes SOS_SCHEDULER_YIELD as a task that voluntarily yielded the scheduler and is waiting in the runnable queue for its next quantum. Microsoft says prolonged waits most often mean queries doing index or table scans, and lists plan regression, missing indexes, statistics updates, and query rewrites as the places to look.

Parallelism waits changed meaning across versions. Since SQL Server 2016 SP2 and 2017 CU3, consumer-side waiting is split into CXCONSUMER, which Microsoft calls a normal part of parallel execution. In SQL Server 2022 and later, and in Azure SQL, CXPACKET covers only threads producing rows, and exchange synchronization moved to CXSYNC_PORT and CXSYNC_CONSUMER.

sql
SELECT TOP (15)
    wait_type,
    wait_time_ms / 1000 AS wait_s,
    signal_wait_time_ms / 1000 AS signal_s,
    CAST(100.0 * signal_wait_time_ms / NULLIF(wait_time_ms, 0) AS decimal(5,1)) AS signal_pct,
    waiting_tasks_count
FROM sys.dm_os_wait_stats
WHERE wait_type IN (N'SOS_SCHEDULER_YIELD', N'CXPACKET', N'CXCONSUMER',
                    N'CXSYNC_PORT', N'CXSYNC_CONSUMER', N'THREADPOOL')
ORDER BY wait_time_ms DESC;

Interpretation: signal_wait_time_ms is the time between a waiting thread being signaled and it actually running, so a high signal share means threads are queuing for CPU. These counters are cumulative since startup. Compare two snapshots taken a few minutes apart. THREADPOOL means tasks are waiting for a worker thread; Microsoft's reference says that most often comes from batches running unusually long, which high CPU causes.

For a full method of snapshotting and ranking waits, see SQL Server wait stats: a diagnostic playbook for slow queries.

Should I change MAXDOP or cost threshold for parallelism?

Only when the waits say parallelism is the problem. The cost threshold for parallelism reference gives the symptoms of a threshold that is too low: too many CPU-light queries go parallel, many Query Store plans have is_parallel_plan = 1, and CXPACKET and CXCONSUMER dominate waits, sometimes with THREADPOOL and SOS_SCHEDULER_YIELD. A threshold that is too high shows SOS_SCHEDULER_YIELD dominating while heavy queries stay serial.

The default cost threshold is 5, which Microsoft calls "a starting point, not a recommendation". It advises raising it in small increments and observing a full business cycle between changes. For MAXDOP, the max degree of parallelism reference recommends, for SQL Server 2016 and later:

Server configurationLogical processorsMicrosoft's MAXDOP guidance
Single NUMA node8 or fewerAt or under the number of logical processors
Single NUMA nodeMore than 88
Multiple NUMA nodes16 or fewer per nodeAt or under the logical processors per node
Multiple NUMA nodesMore than 16 per nodeHalf the logical processors per node, at most 16
sql
-- Current values
SELECT name, value_in_use
FROM sys.configurations
WHERE name IN (N'max degree of parallelism', N'cost threshold for parallelism');

-- Example change, in a reviewed change window
EXECUTE sp_configure 'show advanced options', 1;
RECONFIGURE;
EXECUTE sp_configure 'cost threshold for parallelism', 20;
RECONFIGURE;

Interpretation: both settings take effect without a restart, which also means a bad value reaches production immediately. A value of 0 for MAXDOP lets a query use all available processors up to 64, which Microsoft says is not the recommended value for most cases.

Azure SQL is different

In Azure SQL Database you cannot set cost threshold for parallelism; Microsoft says to use MAXDOP instead. New Azure SQL databases and managed instances default to MAXDOP 8. The Azure guide notes that excessive parallelism usually shows up in databases where MAXDOP was set to 0 on more than eight vCores.

Check the current value in sys.database_scoped_configurations where name = N'MAXDOP', and try a MAXDOP hint on the problem query before changing the whole database.

How do I tell a regressed plan or parameter sniffing from a bad query?

A query that was fine yesterday and burns CPU today usually has a new plan, often because it was compiled for a parameter value that returns few rows and is now reused for values that return millions. Microsoft's step 5 test: free that one plan and see whether CPU drops.

sql
-- Find the plan handle for the statement, then evict only that plan
SELECT cp.plan_handle, cp.usecounts, st.text
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st
WHERE st.text LIKE N'%Orders%CustomerId%';

-- DBCC FREEPROCCACHE (0x06000500...);  -- paste the handle you found

Interpretation: if CPU falls after the new compile and climbs again later, you are looking at a parameter-sensitive plan. Running DBCC FREEPROCCACHE with no argument recompiles every query on the server, which adds CPU during the incident you are trying to end.

Query Store shows the same thing with evidence. Microsoft's Tune performance with the Query Store article has a longer query that lists queries whose average duration doubled after a plan change in the last 48 hours. The shorter version below shows CPU per plan for every query that has more than one plan.

sql
SELECT q.query_id, p.plan_id,
       MIN(rsi.start_time) AS first_seen,
       SUM(rs.count_executions) AS executions,
       AVG(rs.avg_cpu_time) / 1000 AS avg_cpu_ms
FROM sys.query_store_query AS q
JOIN sys.query_store_plan AS p ON p.query_id = q.query_id
JOIN sys.query_store_runtime_stats AS rs ON rs.plan_id = p.plan_id
JOIN sys.query_store_runtime_stats_interval AS rsi
    ON rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id
WHERE rsi.start_time > DATEADD(HOUR, -48, GETUTCDATE())
  AND q.query_id IN (SELECT query_id FROM sys.query_store_plan
                     GROUP BY query_id HAVING COUNT(*) > 1)
GROUP BY q.query_id, p.plan_id
ORDER BY q.query_id, first_seen;

Interpretation: a query whose newest plan has a much higher avg_cpu_ms than an older one has regressed, and the older plan is your candidate for forcing. Check that it was good across many intervals, not one lucky one.

Force the known-good plan as a stopgap

sql
EXEC sp_query_store_force_plan @query_id = 48, @plan_id = 49;

-- Later, once the query or index is fixed
EXEC sp_query_store_unforce_plan @query_id = 48, @plan_id = 49;

Interpretation: per the sp_query_store_force_plan reference, the optimizer produces a plan "the same or similar" to the forced one, and if forcing fails it raises an Extended Event and optimizes normally. You can force only plans Query Store has already recorded for that query. Our Query Store plan regression guide covers the forcing workflow in more depth.

Hints have costs too

Microsoft's step 5 also lists OPTION (RECOMPILE), OPTIMIZE FOR, and USE HINT ('DISABLE_PARAMETER_SNIFFING'). RECOMPILE pays compile CPU on every execution, so avoid it on statements that run thousands of times a minute.

What changed in SQL Server 2022 and 2025 for CPU troubleshooting?

The biggest change is parameter sensitive plan (PSP) optimization. At database compatibility level 160 (SQL Server 2022, Azure SQL Database, Azure SQL Managed Instance), the optimizer can cache a dispatcher plan plus separate query variants for low, medium, and high cardinality ranges of up to three parameterized predicates, so a small-customer and a large-customer call no longer have to share one plan. It works only with equality predicates. SQL Server 2025 at level 170 adds DML support and can select more than one predicate from the same table.

sql
-- Is the database at a level where PSP optimization applies?
SELECT name, compatibility_level FROM sys.databases WHERE name = DB_NAME();

-- Which Query Store queries are PSP variants of a parent query?
SELECT parent_query_id, dispatcher_plan_id, query_variant_query_id
FROM sys.query_store_query_variant;

Interpretation: a database restored or upgraded from an older version keeps its old compatibility level, so a SQL Server 2022 instance can still run a database at level 150 without PSP optimization. Raising it changes optimizer behavior for every query, so capture a Query Store baseline first. To switch PSP off for one database, Microsoft documents ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SENSITIVE_PLAN_OPTIMIZATION = OFF.

CPU troubleshooting features by SQL Server version

Switch versions to see which tools and wait types you will meet

SQL Server 2019

FeatureSQL Server 2019
Query Store on new databasesOff unless enabled
PSP optimizationNot available
CXPACKET coversProducer threads and exchange synchronization
DOP feedbackNot available
Per-scheduler spinlock and signal-time columnsNot available

SQL Server 2022

FeatureSQL Server 2022
Query Store on new databasesOn by default
PSP optimizationCompatibility level 160, SELECT with equality predicates
CXPACKET coversProducer threads only; synchronization in CXSYNC_PORT
DOP feedbackIntroduced
Per-scheduler spinlock and signal-time columnsNot available

SQL Server 2025

FeatureSQL Server 2025
Query Store on new databasesOn by default
PSP optimizationCompatibility level 170 adds DML and several predicates per table
CXPACKET coversProducer threads only; synchronization in CXSYNC_PORT
DOP feedbackAvailable
Per-scheduler spinlock and signal-time columnstotal_signal_time in sys.dm_os_schedulers; spinlock columns need trace flag 8134

Check the database, not the instance: PSP optimization follows the database compatibility level. Sources: Microsoft Learn pages on PSP optimization, sys.dm_os_wait_stats, sys.dm_os_schedulers and MAXDOP.

How do implicit conversions and non-SARGable predicates burn CPU?

Microsoft's step 6 covers predicates SQL Server cannot use an index seek for. Wrapping the column in a function such as SUBSTRING(), CONVERT(), or ISNULL() forces a scan and evaluates the function for every row. The same happens without any function in the text when the data types differ: if a varchar column is compared with an nvarchar parameter, SQL Server converts the column side under data type conversion rules, and the index on that column can no longer be seeked.

sql
-- Top CPU plans in cache whose XML contains an implicit conversion
WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan')
SELECT TOP (20)
    qs.total_worker_time / 1000 AS total_cpu_ms,
    qs.execution_count,
    st.text,
    qp.query_plan
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
WHERE qp.query_plan.exist('//Warnings/PlanAffectingConvert[@ConvertIssue="Seek Plan"]') = 1
ORDER BY qs.total_worker_time DESC;

Interpretation: each row is a cached plan where the optimizer recorded a PlanAffectingConvert warning with ConvertIssue="Seek Plan", meaning a conversion may have prevented an index seek. The pattern follows a Microsoft Azure database support post; the warning flags a possible cause, not a confirmed one. Open the plan, find the conversion warning on the root operator, and fix the type mismatch at the source: the application's parameter type, the ORM mapping, or the column type. Where you cannot change the query, Microsoft suggests a computed column with the same CONVERT() and an index on it.

When are missing indexes or stale statistics the cause?

Microsoft puts these as steps 3 and 4, ahead of query hints. Microsoft's example is sp_updatestats, which runs UPDATE STATISTICS against all user-defined and internal tables in the current database. For a single hot table, a targeted update is faster and easier to reason about.

sql
-- How stale are the statistics on the table behind the top CPU query?
SELECT s.name AS stats_name, sp.last_updated, sp.rows, sp.rows_sampled,
       sp.modification_counter
FROM sys.stats AS s
CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp
WHERE s.object_id = OBJECT_ID(N'dbo.Orders')
ORDER BY sp.modification_counter DESC;

UPDATE STATISTICS dbo.Orders WITH FULLSCAN;

Interpretation: a large modification_counter next to an old last_updated means the optimizer is estimating from data that no longer exists. FULLSCAN reads the whole table, so on a large table run it outside the peak or use a sample. Updating statistics also recompiles dependent plans, which can hide a sniffing problem. For scheduled statistics maintenance, see Ola Hallengren's maintenance solution setup guide.

Then missing indexes, read from the missing-index DMVs:

sql
SELECT TOP (10)
    CONVERT(decimal(28,1), migs.avg_total_user_cost * migs.avg_user_impact
        * (migs.user_seeks + migs.user_scans)) AS improvement_measure,
    mid.statement AS table_name,
    mid.equality_columns, mid.inequality_columns, mid.included_columns,
    migs.user_seeks, migs.last_user_seek
FROM sys.dm_db_missing_index_groups AS mig
JOIN sys.dm_db_missing_index_group_stats AS migs ON migs.group_handle = mig.index_group_handle
JOIN sys.dm_db_missing_index_details AS mid ON mig.index_handle = mid.index_handle
ORDER BY improvement_measure DESC;

Interpretation: Microsoft suggests starting with the top 5 or 10 by improvement_measure and testing each. Its missing index guidance warns that suggestions are pre-execution estimates, can overlap each other and existing indexes, and give no key column order. Every new index also adds write overhead, so combine suggestions with existing indexes where you can and match each one to a statement from your top CPU list before creating it.

What is the step-by-step runbook during an incident?

This runbook condenses the sections above into Microsoft's order for a production instance. Each change is small and reversible, and you measure CPU again after each one.

High CPU runbook for SQL Server and Azure SQL

Seven steps; steps 1 to 3 only read, steps 4 to 7 change something

  1. Confirm sqlservr is the consumer

    Ring buffer split, or perfmon on the host. On Azure SQL Database, read avg_instance_cpu_percent too.

    SELECT end_time, avg_cpu_percent, avg_instance_cpu_percent FROM sys.dm_db_resource_stats ORDER BY end_time DESC;
  2. List running requests by cpu_time

    Record statement, dop, and query_hash before killing anything.

  3. Rank history by total CPU

    Query Store for the incident window, or sys.dm_exec_query_stats if Query Store is off.

  4. Check for a plan change

    If the top statement has a new, worse plan, force the previous one as a stopgap.

    EXEC sp_query_store_force_plan @query_id = 48, @plan_id = 49;
  5. Update statistics on the tables involved

    Targeted, not server-wide, and note that it also recompiles dependent plans.

    UPDATE STATISTICS dbo.Orders;
  6. Fix scans: index, type mismatch, or rewrite

    Test the missing-index suggestion or the conversion fix on a copy before production.

  7. Tune parallelism only if waits point to it

    Raise cost threshold or lower MAXDOP in small steps, then watch a full business cycle.

Main risk: changing several things at once. If CPU falls you will not know which change helped, and if it rises you will not know which to roll back. A forced plan is undone with sp_query_store_unforce_plan.

If every query is reasonable and the combined load still saturates the CPUs, Microsoft's last steps apply: the Windows power plan (Balanced can lower clock speed), overcommitted virtual machine CPUs, then more CPUs or vCores.

Frequently asked questions

How do I find which query is causing high CPU in SQL Server?

Query sys.dm_exec_requests joined to sys.dm_exec_sql_text and sort by cpu_time to see what is running now. For short, frequent queries, rank sys.dm_exec_query_stats by total_worker_time or open Query Store's Top Resource Consuming Queries with the metric set to CPU Time.

Does a high SOS_SCHEDULER_YIELD wait mean I need more CPUs?

Not by itself. SOS_SCHEDULER_YIELD means tasks yielded the CPU and waited for their next turn. Microsoft says prolonged waits most often point to queries scanning indexes or tables, so check plan regressions, missing indexes, and statistics first. Add CPUs only after the top queries are tuned.

What should cost threshold for parallelism be set to?

Microsoft gives no single number. The default of 5 is described as a starting point, not a recommendation, and raising it can keep small OLTP queries serial. Change it in small increments and watch a full business cycle. In Azure SQL Database the setting is not available, so use MAXDOP instead.

Can Query Store fix parameter sniffing automatically?

Partly. In Azure SQL Database, the automatic tuning force plan option detects plan regressions and forces the last good plan, and it is on by default for databases created after March 2020. On SQL Server 2022 and later at compatibility level 160, PSP optimization caches several plans for one parameterized statement. You can also force a plan manually with sp_query_store_force_plan.

Is it safe to run DBCC FREEPROCCACHE during a CPU incident?

Not with no argument. Clearing the whole plan cache forces every query to compile again, which adds CPU load during the incident. Microsoft recommends passing a single plan_handle or sql_handle so only the suspect plan is removed. If CPU drops after that plan is recompiled, the cause is likely a parameter-sensitive plan.

Key takeaways

  • Prove sqlservr owns the CPU before tuning anything; privileged time or another process means the fix is outside SQL Server.
  • Use sys.dm_exec_requests for the query running now and Query Store or sys.dm_exec_query_stats for the query that ran ten thousand times; group by query_hash.
  • Work through Microsoft's order: statistics, missing indexes, parameter-sensitive plans, non-SARGable predicates and implicit conversions, then tracing and server settings.
  • Force a known-good plan with Query Store as a stopgap, and check compatibility level 160 or 170 for PSP optimization on SQL Server 2022 and 2025.
  • Touch MAXDOP and cost threshold for parallelism only when parallelism waits dominate, one small change at a time.

Get help with SQL Server high CPU from JusDB

JusDB's SQL Server performance tuning team can review your top CPU queries and Query Store history, check plan regressions and parameter sensitivity, and recommend index, statistics, and parallelism changes with a rollback for each one.

Bring the incident window, the SQL Server version and compatibility levels, and read access to Query Store. Your team approves every production change.

Share this article

Database engineering notes

Articles like this one, in your inbox. No spam, unsubscribe anytime.

JusDB Team

Official JusDB content team

Keep reading

Database Performance Testing: A Method That Gives Answers You Can Trust

Plan and run a database performance test that answers a real question: test types, production-like data, cache warm-up, workload choice, metrics, repeats and a report template.

PostgreSQL21 minNov 20, 2026
Read

Database Load Testing Tools in 2026: 10 Options Compared

Compare ten database load testing tools, from sysbench and HammerDB to YCSB, k6 and pgreplay, with engines, licences, a real command for each and how to choose.

20 minNov 12, 2026
Read

MySQL Histograms: When the Optimizer Needs Them

Learn when a MySQL histogram beats an index, how to build one with ANALYZE TABLE, how to read its effect in EXPLAIN, and how to keep it fresh with AUTO UPDATE.

MySQL20 minOct 28, 2026
Read