Welcome back. Parallelism is one of the most common reasons a SQL Server instance feels “randomly slow.”
The same query can be fast one moment and slow the next, not because the query changed, but because the server
is making different parallel execution decisions under load.
As a DBA, you must understand parallelism well enough to do three things:
(1) explain it clearly, (2) prevent CPU storms and unstable throughput,
and (3) tune it safely with evidence and validation.
Lesson description: You will learn how SQL Server chooses parallel plans, what
MAXDOP and Cost Threshold for Parallelism actually control, and how to set them using a
job-ready DBA process: baseline → change → validate → document. You will learn how to identify
parallelism-related symptoms (CX* waits, high CPU, query thrash) and how to avoid the most common mistakes
that create outages (MAXDOP = 0 everywhere, Cost Threshold left at 5 forever, or forcing MAXDOP blindly).
SQL Server can execute parts of a query using multiple CPU cores at the same time.
That is called parallelism.
A query runs in parallel when SQL Server decides:
Parallelism can be great for large analytical queries.
But it can be harmful for OLTP systems (many small queries) because:
DBA takeaway: Parallelism is a power tool. Used correctly, it accelerates big work.
Used incorrectly, it creates instability and outages.
MAXDOP sets the maximum number of CPU cores (threads) a single query can use when it runs in parallel.
Important nuance: MAXDOP does not “turn parallelism on.” It caps it.
Whether a query goes parallel is also influenced by Cost Threshold.
Cost Threshold for Parallelism is the “expense gate.”
SQL Server only considers a parallel plan when the optimizer estimates the query cost is higher than this threshold.
Default is often 5, which is very low in modern environments and can cause too many queries to go parallel.
DBA takeaway:
In many real systems, leaving CTFP at 5 results in unnecessary parallel plans,
higher CPU, and unstable throughput.
Here are patterns DBAs see when parallelism settings are wrong:
CXPACKET and CXCONSUMER in wait statsImportant: CX waits alone do not mean “parallelism is bad.”
They mean parallel work is happening. Your job is to evaluate whether it is helping or harming.
In production, DBAs typically do not want one query to take the entire server.
They choose a MAXDOP that balances:
A widely used starting approach (not a blind rule) is:
DBA note (lab vs production): In your lab, you are learning process.
In production, hardware topology (NUMA nodes, core counts) matters. You do not guess.
Cost Threshold determines how “hard” a query must be before SQL Server considers parallelism.
If it is too low, many small queries become parallel.
That often increases CPU overhead and reduces concurrency.
DBAs commonly raise Cost Threshold so that only genuinely expensive queries go parallel.
The exact number depends on workload, but the principle is consistent:
DBA warning: Raising CTFP too high can force large queries to run serially and slow down reporting.
Again: baseline, change, validate.
Run this query to see your current values (configured and in use).
SELECT
name,
value AS configured_value,
value_in_use,
is_dynamic,
is_advanced,
description
FROM sys.configurations
WHERE name IN ('max degree of parallelism','cost threshold for parallelism');
Save output to:
C:\DBA\Baselines\InstanceConfig\parallelism_before_YYYYMMDD_HHMM.txt
Before adjusting parallelism, DBAs capture quick signals:
SELECT TOP (25)
wait_type,
waiting_tasks_count,
wait_time_ms,
signal_wait_time_ms
FROM sys.dm_os_wait_stats
WHERE wait_type NOT IN (
'CLR_SEMAPHORE','LAZYWRITER_SLEEP','RESOURCE_QUEUE','SLEEP_TASK','SLEEP_SYSTEMTASK',
'SQLTRACE_BUFFER_FLUSH','WAITFOR','LOGMGR_QUEUE','CHECKPOINT_QUEUE','REQUEST_FOR_DEADLOCK_SEARCH',
'XE_TIMER_EVENT','XE_DISPATCHER_JOIN','BROKER_TO_FLUSH','BROKER_TASK_STOP','CLR_MANUAL_EVENT',
'CLR_AUTO_EVENT','DISPATCHER_QUEUE_SEMAPHORE','FT_IFTS_SCHEDULER_IDLE_WAIT','BROKER_EVENTHANDLER',
'TRACEWRITE','XE_DISPATCHER_WAIT','BROKER_RECEIVE_WAITFOR','REPUBLISH_QUEUE',
'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP','QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
'SP_SERVER_DIAGNOSTICS_SLEEP'
)
ORDER BY wait_time_ms DESC;
Save output to:
C:\DBA\Baselines\InstanceConfig\waits_before_YYYYMMDD_HHMM.txt
Runnable tasks give a quick indication of CPU queueing.
SELECT
scheduler_id,
runnable_tasks_count,
current_tasks_count,
active_workers_count,
load_factor
FROM sys.dm_os_schedulers
WHERE status = 'VISIBLE ONLINE'
ORDER BY runnable_tasks_count DESC;
Save output to:
C:\DBA\Baselines\InstanceConfig\schedulers_before_YYYYMMDD_HHMM.txt
In a real environment, you would choose values based on workload and approvals.
In your lab, we will practice the correct DBA method:
Lab example commands (use carefully):
Below is a common learning example: set MAXDOP to a moderate number and raise Cost Threshold.
You will adjust the numbers based on your lab CPU count and training goals.
-- Show advanced options if needed EXEC sp_configure 'show advanced options', 1; RECONFIGURE; -- Example: set MAXDOP (limit per-query parallel threads) EXEC sp_configure 'max degree of parallelism', 4; RECONFIGURE; -- Example: raise cost threshold so fewer small queries go parallel EXEC sp_configure 'cost threshold for parallelism', 50; RECONFIGURE;
Important: These values are examples for learning. In production, you select values based on:
hardware topology, concurrency, workload type (OLTP vs DW), and measured evidence.
SELECT
name,
value AS configured_value,
value_in_use
FROM sys.configurations
WHERE name IN ('max degree of parallelism','cost threshold for parallelism');
Save output to:
C:\DBA\Baselines\InstanceConfig\parallelism_after_YYYYMMDD_HHMM.txt
You are not trying to “eliminate CX waits.” You are trying to improve stability and throughput.
After changes, DBAs look for:
In your lab, you validate by re-running your wait and scheduler queries and comparing before/after.
parallelism_before_YYYYMMDD_HHMM.txtwaits_before_YYYYMMDD_HHMM.txtschedulers_before_YYYYMMDD_HHMM.txtC:\DBA\Logs\Changes\change_note_parallelism_YYYYMMDD_HHMM.txtparallelism_after_YYYYMMDD_HHMM.txtwaits_after_YYYYMMDD_HHMM.txtschedulers_after_YYYYMMDD_HHMM.txtNext, you will configure SQL Server memory like a professional DBA.
You will learn how memory pressure causes timeouts, spills, and instability,
how to reserve memory for Windows, and how to validate your memory settings safely.
Not a member yet? Register now
Are you a member? Login now