By: Jeremy Kadlec | Updated: 2006-08-24 | Comments | Related: > Query Optimization
Problem
The Max Degree of Parallelism or MAXDOP is a configuration indicating how the SQL Server optimizer will use the CPUs. This is a server wide configuration that by default uses all of the CPUs to have the available portions of the query executed in parallel. MAXDOP is very beneficial in a number of circumstances, but what if you have a reporting like query that runs in an OLTP system that monopolizes much of the CPU and adversely affects typical OLTP transactions. How can you scale back the CPU usage just for this query?
Solution
Luckily SQL Server 2000 and 2005 provide the OPTION clause which among other configurations, offers the opportunity to specify the MAXDOP for the specific query. This means that a fixed number of CPUs is used for the specific query overriding the server configuration.
If you leave MAXDOP enabled, which is the default, and need to disable it on particular queries, leverage the OPTION code to achieve non parallel processing. This may benefit the situation where OLTP processing is impacted by reporting or batch processing. If you have already disabled MAXDOP, then the OPTION clause can enhance particular queries.
How do I configure the Max Degree of Parallelism at the server level?
SQL Server 2000 | SQL Server 2005 |
|
|
How to configure the number of processors available for parallel queries (Enterprise Manager) | How to: Configure the Number of Processors Available for Parallel Queries (SQL Server Management Studio) |
How can I specify the Max Degree of Parallelism at the query level?
SQL Server 2000 | SQL Server 2005 |
SELECT * FROM Pubs.dbo.Authors OPTION (MAXDOP 1) |
SELECT * FROM Pubs.dbo.Authors OPTION (MAXDOP 1) ; |
OPTION Clause | Query Hint (Transact-SQL) |
Next Steps
- Review your current MAXDOP configurations on your multiple CPU servers. Determine if these configurations would benefit or hinder server wide performance or for specific queries.
- Conduct testing in a test environment to determine the impact of leveraging these configurations at a server and query level.
- Make the decision on the ideal MAXDOP configuration on a per server basis and begin to deploy these configurations. *** NOTE *** - A server reboot may be required to commit the MAXDOP configuration.
- Check out this additional information related to Max Degree of Parallelism:
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2006-08-24