Optimizing Tempdb Performance
Optimizing Tempdb Performance
User Objects
Local and global temporary tables and indexes User-defined tables and indexes Table variables Tables returned in table-valued functions
Internal Objects
Work tables for DBCC CHECKDB and DBCC CHECKTABLE. Work tables for hash operations, such as joins and aggregations. Work tables for processing static or keyset cursors. Work tables for processing Service Broker objects. Work files needed for many GROUP BY, ORDER BY, UNION, and SELECT DISTINCT operations. Work files for sorts that result from creating or rebuilding indexes (SORT_IN_TEMPDB). Storing temporary large objects (LOBs) as variables or parameters (if they wont fit into memory).
The Worlds Largest Community of SQL Server Professionals
Version Stores
The version store is a collection of pages used to store rowlevel versioning of data. There are two types of version stores:
1. Common Version Store: Used when: Building the inserted and deleted tables in after triggers. When DML is executed against a database using snapshot transactions or read-committed row versioning isolation levels. When multiple active result sets (MARS) are used. Online-Index-Build Version Store: Used for online index builds or rebuilds. EE edition only.
2.
3.
LogicalDisk Object: Avg. Disk Sec/Write: The average time, in seconds, of a write of data to the disk. See above guidelines. LogicalDisk: %Disk Time: The percentage of elapsed time that the selected disk drive is busy servicing read or write requests. A general guideline is that if this value > 50%, there is an I/O bottleneck.
DMV
sys.dm_db_file_space_usage
Consider creating an alert on these if you are having space-related tempdb problems.
The Worlds Largest Community of SQL Server Professionals
Be sure autogrowth is turned on for tempdb, and ensure that you have enough available free disk space.
The Worlds Largest Community of SQL Server Professionals
Stop and restart the SQL Server instance Delete the old MDF and LDF files
The Worlds Largest Community of SQL Server Professionals
The above is important because SQL Server uses a proportional fill strategy to fill the physical files, and if the files become different sizes, then tempdb becomes less efficient.
The Worlds Largest Community of SQL Server Professionals
Q&A
Please ask your questions clearly and loudly. If you dont get your questions answered now, see me after the session, or e-mail me.
Contact me at:
[email protected]
Blogs:
www.bradmcgehee.com www.twitter.com/bradmcgehee
Click Here for a free 14-day trial of the Red Gate SQL Server Toolbelt
The Worlds Largest Community of SQL Server Professionals