• subscribe
February 15, 2005 12:00 AM

Tempdb Affects Query Performance During Autogrow

SQL Server Pro
InstantDoc ID #45154
Downloads
45154.zip

The execution time for a particular stored procedure increases 500 percent when we restart SQL Server. Our tests account for the effect of data caching, and the stored procedure's execution plan doesn't change. We don't see drops in performance from our other stored procedures, and the slow procedure's performance returns to normal eventually. How can we tune the slow procedure's performance?

One thing many people forget about in this situation is tempdb's effect on query performance. People also neglect to manually set tempdb to an adequate size, so tempdb autogrows to whatever size it needs as the application runs. Unfortunately, the default size for tempdb is 8MB, and it shrinks to this size when you restart the server. Imagine a situation in which your application forces tempdb to grow to 500MB. Restarting SQL Server shrinks tempdb to 8MB, then when SQL Server restarts, it autogrows back to 500MB again. The autogrow process can be slow and degrade the performance of queries that use tempdb during the autogrow process. I can't say that this is definitely the cause of your performance problems, but it's worth checking if you've investigated other, more obvious possibilities. Run Listing 1 to see what size tempdb was when the server was last started. If tempdb is autogrowing, use the ALTER DATABASE command to set tempdb's size to the maximum size it grows to during normal processing. Remember, setting tempdb to 1MB larger than its current size will force SQL Server to recreate tempdb at that size when it restarts. That's not necessarily what you want, but you want to avoid growing or shrinking databases, including tempdb, during typical production cycles so it's best to plan ahead.



ARTICLE TOOLS

Comments
  • Gad
    5 years ago
    Mar 23, 2007

    Still confused! Do we need to set auto grow to True or set a size and set auto grow to False? Thanks

  • Jay
    7 years ago
    Feb 23, 2005

    I still dont understand what you are trying to say. You dont want us to set the size of tempdb to certain thaing, and dont want to user autogrow..please clarify, if I still need to use auto grow or set a size at which it should start.

  • BURTON
    7 years ago
    Feb 16, 2005

    I thought the tempdb received it's initial settings from the size of the model database. Am I wrong?

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...