Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Azure SQL Managed Instance
This article describes how to configure the cost threshold for parallelism
server configuration option in SQL Server by using SQL Server Management Studio or Transact-SQL.
About cost threshold for parallelism
The cost threshold for parallelism
option specifies the threshold at which SQL Server considers parallel plans on computers with more than one logical processor. The cost threshold for parallelism
option can be set to any value from 0 through 32,767.
Cost is the sum of estimated operator costs in a query plan (for example, CPU and I/O). It's a relative measure used only for plan selection; it doesn't measure actual runtime.
Certain Transact-SQL components can inhibit a parallel plan. For example, noninlineable scalar user-defined functions (UDFs), table variable modifications, and certain system calls. SQL Server evaluates parallel alternatives only when the best serial plan's estimated cost exceeds the cost threshold for parallelism
value, and might then choose a cheaper parallel plan.
Limitations
SQL Server ignores the cost threshold for parallelism
value under the following conditions:
Your computer has only one logical processor.
Only a single logical processor is available to SQL Server because of the
affinity mask
configuration option.The
max degree of parallelism
server configuration option is set to1
.
Recommendations
This option is an advanced option, and should be changed only by an experienced database professional.
The default value of 5
is a starting point, not a recommendation. On modern SQL Server systems, raising it can help to keep smaller OLTP queries executing with serial plans. Use small increments and observe a full business cycle before further changes. Perform application testing with higher and lower values if needed to optimize application performance.
Note
In Azure SQL Database, you can't set cost threshold for parallelism
. Use MAXDOP
to control parallelism instead. For more information, see Changing default MAXDOP in Azure SQL Database and Azure SQL Managed Instance.
In certain cases, a parallel plan might be chosen even though the query's plan cost is less than the current cost threshold for parallelism
value. The decision to use a parallel or serial plan is based on a cost estimate provided earlier in the optimization process. For more information, see the Query Processing Architecture Guide.
Remarks
To see if the cost threshold for parallelism
server configuration option is set too high or too low for your workload, look for the following indicators.
Cost threshold for parallelism setting | Description |
---|---|
Too low | - Too many CPU-light queries go parallel. - In Query Store, many plans have is_parallel_plan set to 1 .- CXPACKET and CXCONSUMER dominate wait type statistics. You might also see THREADPOOL and SOS_SCHEDULER_YIELD waits. |
Too high | - Not enough of the workload's CPU-heavy queries go parallel, and CPU utilization is higher than optimal as a result. - SOS_SCHEDULER_YIELD dominates wait type statistics. |
Permissions
Execute permissions on sp_configure
with no parameters or with only the first parameter are granted to all users by default. To execute sp_configure
with both parameters to change a configuration option or to run the RECONFIGURE
statement, a user must be granted the ALTER SETTINGS
server-level permission. The ALTER SETTINGS
permission is implicitly held by the sysadmin and serveradmin fixed server roles.
Use SQL Server Management Studio
In Object Explorer, right-click a server and select Properties.
Select the Advanced node.
Under Parallelism, change the
cost threshold for parallelism
option to the value you want. Type or select a value from 0 to 32,767.
Use Transact-SQL
This example shows how to use sp_configure to set the value of cost threshold for parallelism
to 20
.
USE master;
GO
EXECUTE sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXECUTE sp_configure 'cost threshold for parallelism', 20;
GO
RECONFIGURE;
GO
EXECUTE sp_configure 'show advanced options', 0;
GO
RECONFIGURE;
GO
For more information, see Server configuration options.
Follow up: After you configure the cost threshold for parallelism option
The setting takes effect immediately without restarting the server.