Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL 2008 R2 tempdb growth/MAXDOP Expand / Collapse
Author
Message
Posted Tuesday, December 11, 2012 3:00 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 22, 2013 10:13 AM
Points: 79, Visits: 200
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.
Post #1395339
Posted Wednesday, December 12, 2012 8:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 22, 2013 10:13 AM
Points: 79, Visits: 200
No thoughts ? Anyone ?
Post #1395698
Posted Wednesday, December 12, 2012 8:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 6:49 AM
Points: 5,216, Visits: 5,110
Can you post the query?



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395704
Posted Wednesday, December 12, 2012 8:38 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, January 16, 2013 4:23 PM
Points: 415, Visits: 2,333
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.
Post #1395709
Posted Wednesday, December 12, 2012 9:16 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 22, 2013 10:13 AM
Points: 79, Visits: 200
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 !! ). 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 !!
Post #1395751
Posted Wednesday, December 12, 2012 9:52 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 22, 2013 10:13 AM
Points: 79, Visits: 200
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.
Post #1395776
Posted Wednesday, December 12, 2012 10:20 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, January 16, 2013 4:23 PM
Points: 415, Visits: 2,333
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.
Post #1395786
Posted Wednesday, December 12, 2012 10:54 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 22, 2013 10:13 AM
Points: 79, Visits: 200
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.
Post #1395811
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse