When this script runs, it identifies resource allocation contention in the PFS, GAM, and SGAM pages in tempdb. The results of this script include the SessionID of the connections causing the contention, the Wait_Time_In_Milliseconds shows how long a latch has been held on a PFS, GAM or SGAM page, and the Type_of_Allocation shows you the type of allocation page that is experiencing the allocation contention. PFS pages generally return 2:1:1, GAM pages generally return 2:1:2, and SGAM pages generally return 2:1:3.
The first number indicates the databaseid, which is 2, as tempdb is always assigned a databaseid of 2. The second number indicates the file number. So a 1 indicates the first file, a 2, the second file, and so on. The third number indicates the page number in the file that represents the type of page. Number 1 represents a PFS page, number 2 represents a GAM page, and number 3 represents a SGAM page. If a PFS, GAM or SGAM is experiencing a high number of latches, especially latches that are held very; this is a strong indicator that the tempdb database needs to be divided into multiple files. By creating multiple files, additional PFS, GAM, and SGAM pages are created, which can reduce contention.
The results of this script are for only the instant that the script is run. Because of this, you may have to run this script multiple times in order to capture what is going on inside your tempdb. If you don't get back any results after multiple tries on your servers, then most likely you don't have a tempdb resource allocation contention problem.On the other hand, be sure to run this script throughout the busy times of the day in order to identify transient problems.
Be sure to research this topic in-depth before creating multiple tempdb files, as this may or may not be the best solution for all SQL Server instances.