views:

324

answers:

3

I have a SQL Server 2005 sp2 box where tempdb has either 8 data files or 5 data files dependingo n where you look. DBCC showfilestates and sys.database_files (both queried in tempdb) show 8 data files (tempdev - tempdev8), however when I query sys.master_files (in master db, which is also what the GUI uses), I only see 5 (tempdev, tempdev5 - tempdev8). I cannot add a tempdev2 - tempdev4 as I get an error that it already exists and I can't restart the SQL Server anytime soon to recreate tempdb.

Anyone know: 1.) how this can happen? 2.) more importantly, how I can correct it?

Thanks,

A: 

The first question I have to ask is, why are you messing with tempdb? Are you experiencing bottlenecks because of tempdb?

Light
We have been experiencing some contention and were going through some best practice excercises to test load on a server and according to http://msdn.microsoft.com/en-us/library/ms175527.aspx :"As a general guideline, create one data file for each CPU on the server."
Vendoran
A: 

If you look on disk in the appropriate directory, how many files do you see?

GilaMonster
I saw all 8 physical files
Vendoran
+1  A: 

It's possible that one view is showing outdated information. One scenario is that those files were dropped from tempdb but SQL Server has not been restarted to delete those files our their entries from some of the system catalog. And you can't add new ones until the old ones are really gone. Anything destructive you do to tempdb (moving, dropping files, etc.) usually requires a restart of SQL Server.

My guess is they are showing two different states of the system and will reconcile one the instance restarts.

Mitch Schroeter