SQL 2008 R2 tempdb growth/MAXDOP

  • We have a certain query that now seems to result in tempdb growing until the disk runs out of space. This has started happening recently, and seems to be very similar to an issue we had about a year ago. The problem is alleviated if you supply a MAXDOP hint with the query and ask the engine to use MAXDOP 1. It looks like there may be a bug whereby the optimizer uses a different DOP and keeps trying to allocate more and more space for a worktable in tempdb until it runs out of space.

    I had opened a case with Microsoft at the time, and they had acknowledged that it was a bug. Anyone know if this has been fixed yet ? I cannot find any references to this bug or its listing as a bug or a resolution. I tried to email the MS case workers on the previous threads when I had opened the case, and the emails bounced back with "access denied" errors. I guess they dont encourage people contacting them after the case is closed.

  • No thoughts ? Anyone ?:Whistling:

  • Can you post the query?

  • I have a thought. The thought is that I hope I don't write a query that blows up tempdb like that in production(not trying to imply that you did)! Whats the actual mechanics of the query that baloons up the tempdb? Is it some sort of concurrent subquery thing or something? I'm always on the lookout for surprises like this, having just recently learned that Microsoft still cannot fundamentally manage storage (http://support.microsoft.com/kb/307487 "can't resize tempdb while in use" also known as failing comp sci 101), I'm sort of trying to collect info traps like this and that.

  • 🙂 Thank you for the replies. The code unfortunately, is confidential. However, it would still be too complex even if I could post it. This is part of the code base for a product and heence so. The query is against a view, which is based on joins two other views(aliased twice each, I think) and a table. The views at this level are also based on one other view and a few tables, with a UNION ALL of 3 queries(Yes I know !! :w00t:). Some of those views also used derived tables in the join etc.

    Its a long story(too long to go into it here) as to why these queries need to be so incredibly complex. However, the bottomline is this: The tables this query goes after may total about 5 GB in data in a database thats about 10 - 12 GB in size, and tempdb bloats up to 70 GB (!!!) if the MAXDOP hint is not supplied. As I mentioned earlier, I had opened a case with MS in July 2011 where they had agreeed that it was a bug. I tested again with SP2, and its only marginally better. On different hardware, on SP2, the query used about 25 GB of tempdb space without the MAXDOP hint. Using MAXDOP 1 reduces tempdb usage to about 4 / 5 GB. Go figure !!

  • patrickmcginnis59 (12/12/2012)


    I'm always on the lookout for surprises like this, having just recently learned that Microsoft still cannot fundamentally manage storage (http://support.microsoft.com/kb/307487 "can't resize tempdb while in use" also known as failing comp sci 101), I'm sort of trying to collect info traps like this and that.

    The surprise(or should it be ??) is that it is a bug, as acknowledged by them more than a year ago. I dont see this as being completely addressed with SP2, and was curious to see if anyone else had run into something like this. We have virtualized all the environments that I had benchmarked this on since this occurred last, and I am not about to go change our production environment to test this out. When the proverbial s**t hit the fan last year, the workaround was to limit the DOP on all queries (by setting MAXDOP in sp_configure) and take it out of the optimizer's hands so we dont run into this again. Who knows how much overhead we are now incurring because it would actually be optimal to parallelize a query !! I would not like to second guess the optimizer if given a choice, but in this instance, we didn't have a choice. I've posted this on MSDN forums too with the case number, and MS techs generally patrol those forums, so I am hoping for something concrete from them.

  • sqlGDBA (12/12/2012)


    patrickmcginnis59 (12/12/2012)


    I'm always on the lookout for surprises like this, having just recently learned that Microsoft still cannot fundamentally manage storage (http://support.microsoft.com/kb/307487 "can't resize tempdb while in use" also known as failing comp sci 101), I'm sort of trying to collect info traps like this and that.

    The surprise(or should it be ??) is that it is a bug, as acknowledged by them more than a year ago. I dont see this as being completely addressed with SP2, and was curious to see if anyone else had run into something like this. We have virtualized all the environments that I had benchmarked this on since this occurred last, and I am not about to go change our production environment to test this out. When the proverbial s**t hit the fan last year, the workaround was to limit the DOP on all queries (by setting MAXDOP in sp_configure) and take it out of the optimizer's hands so we dont run into this again. Who knows how much overhead we are now incurring because it would actually be optimal to parallelize a query !! I would not like to second guess the optimizer if given a choice, but in this instance, we didn't have a choice. I've posted this on MSDN forums too with the case number, and MS techs generally patrol those forums, so I am hoping for something concrete from them.

    So are you saying that the MAXDOP hint to individual queries are ignored, or just that you'd rather not supply the MAXDOP at all? Can you modify problematic queries or do they have to run as is?

    http://www.sqlservercentral.com/Forums/Topic1067746-391-1.aspx <--- interesting thread regarding MAXDOP.

  • No - we would not want to supply individual query hints. I would shy away from second guessing the optimizer with any sort of query hint - Index / join / MAXDOP, you name it. Although God knows I have seen enough instances of each one of those where the optimizer didnt pick the right one.

    We ended up setting the server default to a low number so that the optimizer would see that and not use, say a DOP of 8 to resolve a query and go crazy with tempdb. With a lower setting of MAXDOP at the server level, the optimizer is constrained to only spawn so many threads to resolve any query, and from our observations, also uses a proportionally smaller amount of space in tempdb.

    Very interesting thread indeed - thanks for that;-). Need to digest all the SQLKiwi says there.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply