Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « SQL Server 2008 Service Pack 3 has been releasedSQL Server Views and Metadata »
    comments

    "I see a ton of parallelism in my execution plan I’m tuning.  I read something online and I’m going to alter the value in Maximum Degree of Parallelism (MAXDOP) so they go away."

    This is a very common problem and a very common solution that is found on the great wide internet of SQL and Google search results.  The first thing is, don’t blanket change MAXDOP simply because you read it somewhere or someone says they did it or always do it.  This isn’t a good default thing to set typically.  Some specific database servers can take this type of change but it is more of a diagnosed and specific change. 

    The question in the beginning of this blog is fictitious but let’s pretend it is real and play it out.

    Load up some data into a table.  Remember, Parallelism may only show on a table larger than normal, so load a good deal of data into the table.

    1. CREATE TABLE LotsOhColumns
    2. (
    3.     id int identity(1,1) primary key
    4.     ,fk_id uniqueidentifier
    5.     ,col1 varchar(20)
    6.     ,col2 varchar(20)
    7.     ,col3 varchar(20)
    8.     ,col4 varchar(20)
    9.     ,col5 varchar(20)
    10.     ,col6 varchar(20)
    11.     ,col7 varchar(20)
    12.     ,col8 varchar(20)
    13.     ,col9 varchar(20)
    14.     ,col10 varchar(20)
    15.     ,col11 varchar(20)
    16.     ,col12 varchar(20)
    17. )
    18. GO
    19.  
    20. INSERT INTO LotsOhColumns
    21. SELECT NEWID(),'col1','col2','col3','col4','col5','col6','col7','col8','col9','col10','col11','col12'
    22. GO 3000000

    Now let’s run a basic query on the table

    1. SELECT [fk_id]
    2.       ,[col1]
    3.       ,[col2]
    4.       ,[col3]
    5.       ,[col4]
    6.       ,[col5]
    7.   FROM [XMLContent].[dbo].[LotsOhColumns]
    8. WHERE fk_id = NEWID()

    Looking at this plan, tons of issues come up.  The first one that we insist on tuning is the parallelism and run out to change MAXDOP.  Not yet everyone!

     

    Looking at the query we need a nonclustered index on fk_id and include on the resulting columns.  This should prove to be useful given the results and predicate.

    1. CREATE INDEX IDX_COVERING_ASC ON LotsOhColumns
    2. (
    3.    [fk_id]
    4. )
    5. INCLUDE
    6. (
    7.    [col1]
    8.   ,[col2]
    9.   ,[col3]
    10.   ,[col4]
    11.   ,[col5]
    12. )

    Executing the query again shows a much cleaner plan

    What did we learn here?

    Don't believe everything you read or are told on the internet.  Even this blog should be verified by official documentation and highly skilled experts in the field.  The results shown here is the MAXDOP setting should not be an easy setting to run to when parallelism is shown in execution plans.  Tune the plan and when that is accomplished and if parallelism is truly an issue on your highly active OLTP SQL Server installations, then take a look at MAXDOP.

    Two resources that will assist on this topic greatly are the new book Troubleshooting SQL Server: A Guide for the Accidental DBA, specifically the chapter on CPU and SQL Server.  Also, highly recommend fellow SQL Server MVP Paul White’s paper, “Understanding and Using Parallelism in SQL Server” to read more on effects and why, how SQL Server uses Parallelism. 

    About the Author

    Ted Krueger is a SQL Server MVP and has been working in development and database administration for 13+ years. Specialties range from High Availability and Disaster / Recovery setup and testing methods down to custom assembly development for SQL Server Reporting Services. Ted blogs and is also one of the founders of LessThanDot.com technology community. Some of the articles focused on are Backup / Recovery, Security, SSIS and working on SQL Server and using all of the SQL Server features available to create stable and scalable database services. @onpnt Personal Blog over at http://onpnt.wordpress.com/
    Social SitingsTwitterLinkedInLTD RSS Feed
    959 views
    InstapaperVote on HN

    2 comments

    Comment from: Grant Fritchey [Visitor] · http://www.scarydba.com
    Grant Fritchey Besides, setting the cost threshold for parallelism to something higher than the default value of 5 is a much more useful change.
    10/06/11 @ 12:17
    Comment from: Ted Krueger (onpnt) [Member]
    Ted Krueger (onpnt) Absolutely! Or in some hardcore cases, the MAXDOP hint can be used over a server wide configuration change. Although until last week I had never used the hint in production. :)
    10/06/11 @ 12:23

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)