What Is MAXDOP and Why Does It Matter for SQL Server Performance?
To set MAXDOP in SQL Server correctly, use the formula: set it to the number of physical cores per NUMA node, capped at 8 for most workloads, with a Cost Threshold for Parallelism of at least 50. For servers with fewer than 8 cores, set MAXDOP equal to the core count. For NUMA systems with more than 8 cores per node, set it to half the cores per node, still capped at 8. Apply the setting at both the instance and database level in SQL Server 2016 and later.
That answer covers the majority of environments, but the details matter enormously in practice. MAXDOP (Max Degree of Parallelism) controls how many CPU cores SQL Server can use to execute a single parallel query. Get it wrong and you'll see CXPACKET waits piling up, runaway parallel queries consuming every available core, or conversely, queries that could benefit from parallelism being unnecessarily throttled. In our sql server performance audit work, MAXDOP misconfiguration is one of the most common findings, appearing in well over 80% of environments we assess for the first time.
What Is the Maximum Degree of Parallelism in SQL Server?
The maximum degree of parallelism is a SQL Server configuration option that limits how many processor threads can be used to execute a single query in parallel. The default value is 0, which means SQL Server can use all available logical processors. That default is almost never appropriate for production workloads.
When SQL Server decides to run a query in parallel, it splits the work across multiple threads. MAXDOP caps the number of threads per query. A setting of 1 disables parallelism entirely. A setting of 4 means any single query can use at most 4 cores. The setting applies at three levels: instance, database (SQL Server 2016+), and individual query via the MAXDOP query hint.
The right value depends on your hardware topology, workload type, and whether you're running mixed OLTP and reporting on the same instance.
How to Set MAXDOP in SQL Server: Step-by-Step
Here's the practical process for configuring MAXDOP correctly across different scopes.
Step 1: Understand your hardware topology
Before touching any settings, check your NUMA configuration and core count:
SELECT
cpu_count AS logical_cpus,
hyperthread_ratio,
cpu_count / hyperthread_ratio AS physical_cores,
numa_node_count
FROM sys.dm_os_sys_info;
Also check how cores are distributed across NUMA nodes:
SELECT
memory_node_id,
cpu_count
FROM sys.dm_os_nodes
WHERE node_state_desc <> 'ONLINE DAC';
Step 2: Apply Microsoft's recommended formula
Microsoft's official guidance (documented in KB2806535) recommends:
- Servers with fewer than 8 logical processors: set MAXDOP to the number of logical processors
- Servers with 8 or more logical processors: set MAXDOP to 8
- NUMA servers with more than 8 logical processors per NUMA node: set MAXDOP to half the number of logical processors per NUMA node, capped at 8
- Hyperthreading enabled: do not exceed the number of physical cores per NUMA node
Step 3: Set MAXDOP at the instance level
EXEC sys.sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sys.sp_configure 'max degree of parallelism', 8;
RECONFIGURE;
Verify the change:
SELECT name, value, value_in_use
FROM sys.configurations
WHERE name = 'max degree of parallelism';
Step 4: Set MAXDOP at the database level (SQL Server 2016 and later)
Database-scoped configuration lets you override the instance setting for specific databases. This is particularly useful when you have a reporting database on the same instance as an OLTP database.
-- Allow more parallelism for a reporting database
ALTER DATABASE ReportingDB
SET MAXDOP = 4;
-- Disable parallelism for a sensitive OLTP database
ALTER DATABASE OltpDB
SET MAXDOP = 1;
-- Revert to instance-level setting
ALTER DATABASE OltpDB
SET MAXDOP = 0;
Step 5: Override at query level when needed
For individual queries where you know the optimal parallelism level:
SELECT *
FROM dbo.LargeFactTable
WHERE SalesDate >= '2024-01-01'
OPTION (MAXDOP 4);
What Should Cost Threshold for Parallelism Be Set To?
MAXDOP doesn't work in isolation. Cost Threshold for Parallelism determines when SQL Server considers using parallelism at all. The default is 5, which is laughably low by modern standards. It was set in the mid-1990s when hardware was dramatically slower.
With a threshold of 5, SQL Server will attempt to parallelise even trivial queries, generating unnecessary overhead and contributing to CXPACKET and CXCONSUMER waits. Most environments should set this to at least 50. High-volume OLTP systems often benefit from values between 50 and 100.
EXEC sys.sp_configure 'cost threshold for parallelism', 50;
RECONFIGURE;
To check your current wait statistics and see whether CXPACKET waits are a problem:
SELECT
wait_type,
waiting_tasks_count,
wait_time_ms,
wait_time_ms / NULLIF(waiting_tasks_count, 0) AS avg_wait_ms
FROM sys.dm_os_wait_stats
WHERE wait_type IN ('CXPACKET', 'CXCONSUMER', 'CXSYNC_PORT', 'CXSYNC_CONSUMER')
ORDER BY wait_time_ms DESC;
If CXPACKET waits are consistently in your top 5 wait types, both MAXDOP and Cost Threshold for Parallelism deserve immediate attention.
Common MAXDOP Mistakes That Hurt SQL Server Performance
Knowing how to set MAXDOP in SQL Server is one thing. Knowing what not to do is equally important.
Leaving MAXDOP at 0 on large servers. On a 32-core server, a single poorly written query can consume all 32 cores and starve everything else. This is the most common finding in sql server health check engagements.
Setting MAXDOP to 1 globally. Some DBAs overcorrect and disable parallelism entirely. This kills performance for legitimate analytical queries and reporting workloads. Parallelism exists for a reason.
Ignoring NUMA boundaries. Setting MAXDOP higher than the number of cores per NUMA node causes cross-NUMA memory access, which adds latency. Always check your NUMA topology first.
Setting database-level MAXDOP without understanding the workload. A blanket database-level setting applied without analysing query patterns can be just as harmful as the wrong instance-level setting.
Not pairing MAXDOP with Cost Threshold for Parallelism. These two settings work together. Tuning one without the other leaves significant performance on the table.
Applying the same MAXDOP to every environment. A 4-core development VM and a 64-core production server have completely different requirements. Standardising on a single value across environments is a common mistake in organisations without dedicated sql server performance tuning processes.
MAXDOP in Azure SQL Database and SQL Managed Instance
Azure SQL Database and SQL Managed Instance handle MAXDOP differently from on-premises SQL Server. In Azure SQL Database, the default MAXDOP is 8 for databases with 8 or more vCores, and equals the vCore count for smaller tiers. You can't set it at the instance level since you don't have access to sp_configure.
Set it at the database level instead:
ALTER DATABASE SCOPED CONFIGURATION
SET MAXDOP = 4;
Check the current setting:
SELECT name, value
FROM sys.database_scoped_configurations
WHERE name = 'MAXDOP';
For SQL Managed Instance, you do have access to sp_configure and can set MAXDOP at the instance level as you would on-premises. Our remote sql server support team regularly assists clients migrating to Azure who discover their on-premises MAXDOP assumptions don't translate directly to the cloud.
Key Takeaways
- Set MAXDOP to the number of physical cores per NUMA node, capped at 8 for most workloads. Never leave it at the default of 0 on servers with more than 8 logical processors.
- Always raise Cost Threshold for Parallelism to at least 50 alongside any MAXDOP change. These settings must be tuned together.
- Use database-scoped MAXDOP (SQL Server 2016+) to apply different parallelism settings to OLTP and reporting databases on the same instance.
- Check sys.dm_os_wait_stats for CXPACKET and CXCONSUMER waits before and after making changes to validate the impact.
- Azure SQL Database requires database-level configuration via ALTER DATABASE SCOPED CONFIGURATION since sp_configure is not available.
What to Do Next
MAXDOP is one configuration setting. It's rarely the only thing misconfigured. In a typical sql server health check engagement, DBA Services identifies an average of 12 or more configuration and performance issues per instance, ranging from missing indexes and outdated statistics through to memory pressure, TempDB contention, and backup failures waiting to happen.
If you're not certain your MAXDOP is set correctly, or you want a complete picture of your SQL Server environment's health, DBA Services offers structured sql server performance audit services and ongoing managed sql server services for organisations across Australia. Our team provides hands-on sql health check assessments and ongoing remote sql server support, giving you the expertise of a senior DBA without the overhead of a full-time hire.
Contact DBA Services to arrange a SQL Server health check and find out exactly where your environment stands.
Get a SQL Server Health Check for $999
Find out what's really going on inside your SQL Server environment. We find critical misconfigurations in 97% of reviews, with a full 48-hour performance baseline and a prioritised action plan.
$999 ex-GST
normally $2,499
For your first SQL Server instance; additional instances are 2 hours each.