SQL Server MAXDOP and parallelism
At our company, we have a 4 core blade running SQL Server 2008 Enterprise Edition.
This is a very, very busy SQL Server and is running on HP EVA hardware, so the I/O is not an issue.
We have over 50 warehouses all running SQL Server 2008 and replicating data to/from this primary database.
This database is also used by our website, webservices and import/export applications. The only thing this database does not serve is our SSRS reports, which are hosted on another blade.
What is an issue, however, are the CPU's. They were very busy. To help with this we can play around with two settings on SQL Server:
Our DBA and I had a few discussions around this recently. Read plenty of articles on it, such as Adam Machanic
On a normal system, leaving these settings alone are fine, but on a very very busy system you need to change them.
This is because running complex queries faster made the replication suffer. By using MAXDOP=1 we save CPU time by not having to join up parallel queries at the end. Save time by stopping the "thread thrashing" that can occur on many queries all running in parallel.
Because the SQL box is very busy fielding many queries at once, using MAXDOP=1still utilises all cores due to running 4 or more queries at the same time.
Also replication is a lot happier now.
This is a very, very busy SQL Server and is running on HP EVA hardware, so the I/O is not an issue.
We have over 50 warehouses all running SQL Server 2008 and replicating data to/from this primary database.
This database is also used by our website, webservices and import/export applications. The only thing this database does not serve is our SSRS reports, which are hosted on another blade.
What is an issue, however, are the CPU's. They were very busy. To help with this we can play around with two settings on SQL Server:
- MAXDOP (Max degree of parallelism)
- Cost threshold for parallelism
Our DBA and I had a few discussions around this recently. Read plenty of articles on it, such as Adam Machanic
On a normal system, leaving these settings alone are fine, but on a very very busy system you need to change them.
- MAXDOP=1. What this does is to always use 1 core for the query.
- MAXDOP=0, Cost = 20. This will use 1 core for simple queries, and for complex queries (cost > 20) will be allowed to use parallel queries.
This is because running complex queries faster made the replication suffer. By using MAXDOP=1 we save CPU time by not having to join up parallel queries at the end. Save time by stopping the "thread thrashing" that can occur on many queries all running in parallel.
Because the SQL box is very busy fielding many queries at once, using MAXDOP=1still utilises all cores due to running 4 or more queries at the same time.
Also replication is a lot happier now.