2@SQLSoldier Who am I? www.sqlsoldier.com 11+ Former Sr. Production DBA / Operations Engineer in PQO OperationsFormer Technical Lead of the PQO Operations SQL V-TeamProgram Manager for SQL Server Certified Master program in Microsoft LearningMicrosoft Certified Master: SQL Server 2008MCITP: Database Developer: SQL Server 2005 and 2008MCITP: Database Administrator: SQL Server 2005 and 2008Co-author of Pro SQL Server 2008 MirroringIdera ACE (Advisors & Community Educators)Host of T-SQL Tuesday, July 2010Guest Professor at SQL University, summer 2010, spring/summer 2011Speaker at SQL PASS Summit 201011+ years working with SQL ServerWriter for SQL Server MagazineMember: MensaMiddle picture: Maggie and WoodyBlog:Twitter:11+
3It depends? How many data files? Should I separate the log and data files?What RAID level?What about RAM drives or SSDs?Is there such a thing as too many data files?
4What is tempDB? Well organized junk drawer of SQL Server Temporary objectsInternal objects (work tables)Version storeSnapshot isolationRead committed snapshot isolationOnline index operationsMARSAfter TriggersTrigger virtual tables
5How many data files? 1:1? Official Microsoft recommendation still 1:1 Tested by PSS/SQL team on SQL 2008 R2 on SQL Server with > 64 logical CPUsActual need: 1 per concurrent process using tempDBIs this a realistic recommendation?
6How many data files, really? Systems that need 1:1 data files are fewEvidence indicates that performance does degrade somewhat with more filesAverage I/O block size decreasedData access patterns appear randomMost SQL Servers may not need more than 1:4 or 1:2 data files per logical CPUsThis is only a starting point
7Start with 1:4 or 1:2 data files? It depends!What is your comfort level with dealing with tempDB contention?Can you recognize it?Do you know how to fix it?Are you actively monitoring for it?If it occurs, are you okay with the time it would take to respond to and fix it?
8What is tempDB contention? Latch contention on allocation pagesPFS: Page Free SpacePage 1 and every 8088 pagesGAM: Global Allocation MapPage 2 and every 511,232 pagesSGAM : Shared Global Allocation MapPage 3 and every 511,232 pagesPAGEIOLATCH_xx waitsPAGELATCH_xx waits
9Monitoring tempDB Contention Use DMV sys.dm_os_waiting_tasksParse resource_description column<database ID>:<file ID>:<page number>Database ID = 2 for tempDBFile ID = ID of a data filePage number = do the mathGAM: (Page ID – 2) %SGAM: (Page ID – 3) %PFS: (Page ID – 1) % 8088
15RAID Levels & RAM Disk subsystem can affect performance TempDB tries to maintain as much as it can in memoryTry to avoid DDL on temporary tables after they are createdLarge sorts or hashes can spill over from memory into tempDBWatch for IO_COMPLETION and PAGEIOLATCH_xx waits
16RAID Levels & RAMOn a well-tuned system, RAM more important to me than RAID levelStatistics are important!If queries spill to tempDB, you will notice the difference in disk performanceRAID 1 or RAID 10 (RAID 1,0)Look at the whole disk subsystem, not just RAID level
18RAM disk & SSDs Yes, the fastest disk subsystems (to date) Will you need that level of disk performance?RAM disk – You will have to recreate the tempDB files are startupA large log file will delay tempDB startup
19TempDB on FusionIOWP: Performance Evaluation of Hosting TempDB on FusionIOSaw great increases in performance metricsSaw minimal increase in actual throughput
20Final thoughts! Configuration is key Monitor for tempDB contention Data files 1:1 vs 1:2 or 1:4Data files all the same size and settingsMonitor for tempDB contentionRAM and disk subsystemRAM Disk & SSDs
21Thanks! Thanks for joining! Thanks to Idera and MSSQLTips for sponsoring!Session files will be available atMy blog:Twitter: twitter.com/SQLSoldier