views:

72

answers:

3

I have read that it is a good idea to have one file per CPU/CPU Core so that SQL can more efficiently stream data to and from the disks. Ok, I can see the benefit if they are on different spindles, but what if I only have one spindle (4 drives in Raid 10) for my data files (.mdf and .ndf), will I still benefit from splitting the data files (from just the .mdf file to a .mdf and several .ndf files)? Same goes for the log file, although I see no benefit to it as the data has to be written serially and you're limited by the spindle's sequential write speed...

FYI, this is in regards to SQL Server 2005/2008...

Thanks.

A: 

Still good. This is not about IOPS - it is about SQL Server BLOCKING a file for certain operations. mostly when file extends are allocated to a table / index. If you do a lot of inserts / updates, multiple files basically mean another thread will block another file, not wait on the first one.

So, this is not really about IOPS loads, it is about a blocking behavior.

TomTom
So files that are getting a lot of reads and writes (like the tempdb possibly) would benefit from three or four .ndf files? What about the log file?
No not at all, the entire point behind multiple files is to reduce the amount of PFS. GAM or SGAM contention on the files through the porportionate fill mechanisms of SQL Server. Unless you have demonstated contention on one of these AUN's adding multple files is nothing more then that, adding more files for the sake of adding files. In this case @TomTom has no idea what he is talking about.
Jonathan Kehayias
+1  A: 

8 Steps to better Transaction Log throughput:

Create only ONE transaction log file. Even though you can create multiple transaction log files, you only need one... SQL Server DOES not "stripe" across multiple transaction log files. Instead, SQL Server uses the transaction log files sequentially.

Misconceptions around TF 1118:

Why is the trace flag not required so much in 2005 and 2008? In SQL Server 2005, my team changed the allocation system for tempdb to reduce the possibility of contention. There is now a cache of temp tables. When a new temp table is created on a cold system (just after startup) it uses the same mechanism as for SQL 2000. When it is dropped though, instead of all the pages being deallocated completely, one IAM page and one data page are left allocated, and the temp table is put into a special cache. Subsequent temp table creations will look in the cache to see if they can just grab a pre-created temp table 'off the shelf'. If so, this avoids accessing the allocation bitmaps completely. The temp table cache isn't huge (I think it's 32 tables), but this can still lead to a big drop in latch contention in tempdb.

So the answer is NO to both questions. Log striping was never an issue, and one-NDF-per-CPU is largely a myth, one that will take a very long time to die out. Multiple files IMHO make sense only if you can stripe IO (separate LUNs). Multiple filegroups though make sense, but not for IO reasons, for administrative purposes: piecemeal restores and archive read-only filegroups.

Remus Rusanu
Also http://sqlblog.com/blogs/linchi_shea/archive/2009/10/01/sql-server-challenge-show-me-trace-flag-1118-is-significant.aspx
Remus Rusanu
Why do you consider multiple data files in relation to cores a myth? Only just last week at the SQLBits conference the SQLCAT team recommended as a general guideline 1 data file per core, up to 16 cores!
John Sansom
@John Sansom: I say if you have a workload that has allocation contention as to require one file per CPU, you need a budget way above asking questions in a forum. In other words if you ask about it, you don't need it.
Remus Rusanu
Allocation contention can be measured: http://blogs.msdn.com/b/sqlserverstorageengine/archive/2009/01/11/tempdb-monitoring-and-troubleshooting-allocation-bottleneck.aspx . Unless the real workload measured data shows that it *does* happen, there is no reason to do it. It just adds unnecessary administration pain.
Remus Rusanu
@Remus Rusanu: ha ha I can see your point :-) although I still don't think it correct to declare the configuration a myth, it just depends on your requirements.
John Sansom
+3  A: 

The recommendation for multiple tempdb data files is definitely not about IOPS. It is about contention on the allocation pages (GAM, SGAM, PFS) in tempdb. SQL 2005+ doesn't require as big of a load on these pages, but contention still occurs. Not all system require a 1 file to 1 core mapping. Most sytems will perform well with 1 file to 2 or 4 cores. Having too many files adds overhead for managing the files. A good recommendation is to start with 1:4 or 1:2 and increasing if contention continues. Don't go above 1:1.

For other databases, this is not recommended.

And yes, only 1 log file ... always.

Robert L Davis
No, never. Log files - same. One per processor core.
TomTom
Sorry @TomTom, but you are wrong and prevailing empiracle evidence proves such to be true. Log files are sequentially written to so multiple files has no entrinsic value to the system. You might as well smoke dope or drink beer, and expect that that will improve performance over having multiple log files. The only benefit to multiple log files is a scenario where log backups can't keep up with the amount of log generated over a period of time.
Jonathan Kehayias