Tempdb allocation contention

If your code uses temporary tables, variable tables or dynamic cursors, this metric can help identify whether you have contention on tempdb allocation.

Install metric...

Metrics install automatically if you have Redgate Monitor installed.

If you are using Redgate’s SQL Server monitoring tool, Redgate Monitor, you can instantly install and run this metric on your servers.

If your code uses temporary tables, variable tables or dynamic cursors, this metric can help identify whether you have contention on tempdb allocation. Tempdb is shared by all databases and is used for many operations in a SQL Server instance, so it is common for tempdb to cause performance problems.

The T-SQL returns the current number of pagelatch waits on the tempdb database. Any tempdb page allocation/deallocation or any space changing operations (such as INSERT) acquires a latch on PFS, SGAM or GAM pages to update the space tracking information. Since most temporary objects are heaps and are less than 64KB, a large number of such operations can cause excessive waits when acquiring latches.

The following query can be used to help you in a further analysis on which type of page (PFS, GAM or SGAM) is causing allocation waits on tempdb:

For more information about tempdb, see http://technet.microsoft.com/en-us/library/cc966545.aspx.

For more information about tempdb contention, see http://www.sqlservercentral.com/blogs/robert_davis/2010/03/05/Breaking-Down-TempDB-Contention/.

Metric definition

Name

Tempdb allocation contention

Description

This metric can help identify whether you have contention on tempdb allocation by measuring pagelatch waits.

The T-SQL query that will collect data

Instances to collect from

Select all

Databases to collect from

master

Collection frequency

60

Use collected or calculated values

Leave the Use a calculated rate of change between collections check box unchecked

Metric collection

Enabled

Alert definition

Alert name

Tempdb allocation contention

Description

This alert is raised when the number of pagelatch waits on the tempdb database increases to match the alert thresholds.

Raise an alert when the metric value goes

Above the defined threshholds

Default threshold values

High:50
Medium:10
Low:0

Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.

Raise an alert when the threshold is passed for

1 collection

Alert is

Enabled