[Reference] SQL Server tempdb optimization tips

Source: Internet
Author: User

This article is from http://stackoverflow.com/users/6461/splattne. Thanks to his effort.

 

In order to optimize tempdb performance pay attention to physical disk configuration, file configuration, as well as some settings within the database.

Physical disk configuration

Tempdb shocould reside on itsOwn dedicated physical disks. This allows it to split I/O transactions from the remainder of volumes on the SQL server.

To move tempdb to a new disk drive, useAlter Database. It is the key T-SQL command to perform this operation. Microsoft offers a good example in SQL Server 2005 books online. The article name is alter database (TRANSACT-SQL) and the specific section is'G. Moving tempdb to a new location .'

The tempdb is a very high-write database. So, a RAID 5 array isn't the proper place for it. You shoshould put the tempdbOn either a RAID 1 or raid 10 ArrayAs they're optimized for High-write applications. If you can afford additional RAID 1 or raid 10 Arrays for each physical database file for the tempdb, you'll get increased performance.

Database Files

You shoshould haveOne physical file per CPU core in the server. So, if you have a dual-chip, dual-core server, you shoshould have four physical database files for the tempdb database. when adding more database files, it's important to configure the files atSame initial size and with the same growth settings. That way, SQL Server will write the data into ss the files as evenly as possible.

Database File Size

The size of the tempdb database can affect the performance of a system. For example, if the size that is defined for tempdb is too small, part of the system-processing load may beTaken up with autogrowing tempdb to the size required to support the workload every time you restart the instance of SQL Server. You can avoid this overhead by increasing the sizes of the tempdb data and log file.

Determining the appropriate size for tempdb in a production environment depends on login factors including the existing workload and the SQL server features that are used. microsoft recommends that you analyze the existing workload by grouping the following tasks in a SQL ServerTestEnvironment:

    1. Set autogrow on for tempdb(In a test environment !).
    2. Execute individual queries or workload trace files and monitor tempdb space use.
    3. Execute index maintenance operations, such as rebuilding indexes and monitor tempdb space.
    4. Use the space-use values from the previous steps to predict your total workload usage; adjust this value for projected concurrent activity, and then set the size of tempdb accordingly.

Minimum Size recommendations for tempdb are as follows:

   Envir  .     Size  DB  Size     (  MB )    Log     Size     (  MB  )  
----------- ------------ -------------
Small 1024 256
Medium 5120 1024
Large 10024 2048

Database settings

You can further increase tempdb performanceDisabling the auto update stats, Which will save your tempdb some work. You can also setAuto create statistics option to false.

Disclaimer: settings shocould be changed with care. Depending on the kind of load you place on your tempdb, changing settings cocould adversely impact system performance.

To achieve optimal tempdb performance, follow the guidelines and recommendations provided in optimizing tempdb performance.

How to monitor tempdb usage?

RunningOut of disk space in tempdbCanCause significant disruptionsIn the SQL Server production environment and can prevent applications that are running from completing operations.

You can useSYS. dm_db_file_space_usageDynamic management view to monitor the disk space that is used by these features in the tempdb files. additionally, to monitor the page allocation or deallocation activity in tempdb at the session or task level, you can useSYS. dm_db_session_space_usageAndSYS. dm_db_task_space_usageDynamic management views.

These views can be used to identify large queries, temporary tables, or table variables that are using lots of tempdb disk space. there are also several counters that can be used to monitor the free space that is available in tempdb and also the resources that are using tempdb.

Links:

    • Microsoft technet: Working with tempdb in SQL Server 2005
    • searchsqlserver.com: SQL Server tempdb best practices increase performance
    • msdn Library: optimizing tempdb performance
    • searchsqlserver.com: Configure SQL Server 2005 tempdb for performance
    • msdn Library: Capacity Planning for tempdb
    • msdn Library: troubleshooting insufficient disk space in tempdb
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.