Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Configuring tempdb

Author  Topic 

ranvir_2k
Posting Yak Master

180 Posts

Posted - 2011-01-31 : 13:38:40
Does anyone know the best practices when configuring tempdb in sql 2008? I have heard that tempdb should have it's own dedicated drive and that the data files should be split across 9 different files.

Can you please tell me why the data should span 9 files? How did someone arrive at this figure?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-31 : 13:42:30
Where did you hear that it should have 9 data files? That is completely false.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-02-01 : 01:26:56
The recommendation for TEMPDB is 1 data file per CPU.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-02-01 : 07:11:28
quote:
Originally posted by sql_server_dba

The recommendation for TEMPDB is 1 data file per CPU.

Per cpu core isn't it...?

- Lumbago
My blog-> www.thefirstsql.com
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2011-02-01 : 10:38:09
It should be equal to number of processors. Create it with Equal size.

Reason:
from KB Article:

During object creation, two (2) pages must be allocated from a mixed extent and assigned to the new object. One page is for the Index Allocation Map (IAM), and the second is for the first page for the object. SQL Server tracks mixed extents by using the Shared Global Allocation Map (SGAM) page. Each SGAM page tracks about 4 gigabytes of data.

As part of allocating a page from the mixed extent, SQL Server must scan the Page Free Space (PFS) page to find out which mixed page is free to be allocated. The PFS page keeps track of free space available on every page, and each PFS page tracks about 8000 pages. Appropriate synchronization is maintained to make changes to the PFS and SGAM pages; and that can stall other modifiers for short periods.

When SQL Server searches for a mixed page to allocate, it always starts the scan on the same file and SGAM page. This results in intense contention on the SGAM page when several mixed page allocations are underway, which can cause the problems.
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-02-04 : 13:04:11
I am not to sure why does Microsoft recommends of having 1 data file per CPU in the first place.I mean I never could understand the reason for this benchmark.

If you have no issues with allocation page contention then having multiple files wont be of much help.To monitor the allocation contention you can use the sys.dm_os_waitingtasks DMV and check for the columnname "wait_type" and value "PageLatch".Only go for multiple data files if you have issues with allocation contention.And if you do decide to go for multiple data files make sure that all the tempdb data files are of the same size.

Also if a lot of work tables are created due spools or sort operations having multiple data file is only going to degrade the performance.Because these operations are sequential which will create multiple streams of sequential I/O and until you don't have a subsystem capable of handling concurrent streams it will hurt performance.

Please take all this point into consideration and then only go ahead with multiple files for tempdb.

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-04 : 13:08:21
Microsoft has actually backed away from the 1 data file per CPU. They still do recommend multiple tempdb data files, however it's lower than 1 data file per CPU in most cases. They have encountered one customer that need 2 data files per CPU to get through a bottleneck. It's usually 1/2 a data file per CPU, so 2 for 4 CPUs. Everyone's mileage will vary.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-02-04 : 13:31:34
Also Microsoft documented there wont be any performance benefits if you exceed 8 data files.

Do you have any idea why Microsoft only recommends the no of datafiles based on the physical CPU cores and not the logical cores also?

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-04 : 13:47:34
Microsoft's documentation is incorrect then as they have one customer that requires either 32 or 64 data files for tempdb, and they have like 16 CPUs.

Their recommendation IS based upon the logical CPUs and not the physical CPUs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -