• subscribe
June 17, 2003 12:00 AM

Determining Tempdb's File Size

SQL Server Pro
InstantDoc ID #39157
Downloads
39157.zip

How can I find the size of the files in tempdb when SQL Server was last started? I know that each time I stop and start SQL Server, it drops, then recreates tempdb. So, SQL Server resets the size of the tempdb files to their original size as of the last SQL Server restart or to the size the files were last manually set to through an ALTER command. I know that performance can decrease if my tempdb files need to grow substantially during normal processing. I'd like to see how much tempdb files have grown so that I can determine whether to manually set them to a larger size.

There isn't an obvious way to determine how much tempdb files have grown since the last time SQL Server was restarted. As much as Microsoft chastises us for directly accessing system tables, the answer to this question is an example of when you need to read system tables to get the information you seek.

I don't have space to fully discuss the sysaltfiles table located in the master database or the sysfiles table located in each database. I can say that a row exists in the master..sysaltfiles table for each file in tempdb, and a corresponding row exists in the sysfiles table within tempdb. The size column in sysaltfiles will help you determine the size of the files within tempdb when SQL Server was last started. The size column in tempdb..sysfiles shows the current size of the files. These sizes will be different if SQL Server has auto-grown the files. The size column in each table tracks the number of 8K pages assigned to the files. Therefore, the query that Listing 1 shows returns the original and current size of all files in the tempdb database.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
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 ...