Concurrency enhancements for the tempdb database
This article was previously published under Q328551 BUG #: 362099 (SHILOH_BUGS) On This PageSYMPTOMSWhen the tempdb database is heavily used, SQL Server may experience contention
when it tries to allocate pages. From the sysprocesses system table output, the waitresource may show up as "2:1:1" (PFS Page) or "2:1:3" (SGAM Page). Depending on the degree of contention, this may also lead to SQL Server appearing unresponsive for short periods. These operations heavily use tempdb:
CAUSEDuring object creation, two (2) pages must be allocated from
a mixed extent and assigned to the new object. One page is for the Index
Allocation Map (IAM), and the second is for the first page for the object. SQL
Server tracks mixed extents by using the Shared Global Allocation Map (SGAM)
page. Each SGAM page tracks about 4 gigabytes of data. As part of allocating a page from the mixed extent, SQL Server must scan the Page Free Space (PFS) page to find out which mixed page is free to be allocated. The PFS page keeps track of free space available on every page, and each PFS page tracks about 8000 pages. Appropriate synchronization is maintained to make changes to the PFS and SGAM pages; and that can stall other modifiers for short periods. When SQL Server searches for a mixed page to allocate, it always starts the scan on the same file and SGAM page. This results in intense contention on the SGAM page when several mixed page allocations are underway, which can cause the problems documented in the "Symptoms" section of this article. Note De-allocation activities must also modify the pages, which can contribute to the increased contention. To learn more about the different allocation mechanisms used by SQL Server (SGAM, GAM, PFS, IAM), see the "References" section of this article. RESOLUTION To reduce the allocation resource contention for tempdb that is experiencing heavy usage, follow all these steps:
With regard to step 2, the use of trace flag -T1118 for Microsoft SQL Server 7.0, before you use the trace flag, see the following article in the Microsoft Knowledge Base: 813492 (http://support.microsoft.com/kb/813492/) FIX: Create index fails on SQL Server 7.0 when trace flag 1118 is enabled
Service pack informationTo resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For more information, click the following article number to view the article in the Microsoft Knowledge Base:290211 (http://support.microsoft.com/kb/290211/) How to obtain the latest SQL Server 2000 service pack
Hotfix informationHotfix 8.00.0702The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.Date Time Version Size File name ---------------------------------------------------------------- 30-Aug-2002 21:08 786,432 Distmdl.ldf 30-Aug-2002 21:08 2,359,296 Distmdl.mdf 09-Oct-2002 00:54 544 Drop_repl_hotfix.sql 02-Jul-2002 15:35 2000.80.650.0 107,088 Impprov.dll 19-Jul-2002 16:56 774,516 Instdist.sql 08-Oct-2002 23:56 12,615 Inst_repl_hotfix.sql 20-Aug-2002 16:24 2000.80.679.0 111,172 Logread.exe 07-Apr-2002 02:08 2000.80.606.0 62,024 Odsole70.dll 03-Jan-2002 01:59 18,185 Qfe356326.sql 20-Aug-2002 16:47 2000.80.679.0 135,748 Qrdrsvc.exe 26-Aug-2002 22:49 2000.80.679.0 406,088 Rdistcom.dll 04-Oct-2001 01:36 437,302 Replcom.sql 20-Aug-2002 16:33 2000.80.679.0 152,136 Replmerg.exe 19-Nov-2001 20:36 993,945 Replmerg.sql 05-Nov-2002 23:48 2000.80.700.0 221,768 Replprov.dll 04-Oct-2001 01:36 986,906 Replsys.sql 04-Oct-2001 01:36 881,228 Repltran.sql 26-Aug-2002 22:49 2000.80.679.0 283,208 Rinitcom.dll 16-Sep-2002 22:31 390,045 Securityhotfix.sql 26-Aug-2002 22:49 2000.80.679.0 28,672 Sqlagent.dll 26-Aug-2002 18:39 2000.80.679.0 311,872 Sqlagent.exe 28-Aug-2002 16:32 2000.80.679.0 49,152 Sqlagent.rll 26-Aug-2002 22:49 2000.80.679.0 53,824 Sqlcmdss.dll 28-Aug-2002 16:40 2000.80.679.0 12,288 Sqlcmdss.rll 24-Oct-2002 17:37 2000.80.695.0 176,696 Sqlmap70.dll 11-Nov-2002 09:52 2000.80.702.0 7,471,185 Sqlservr.exe 11-Nov-2002 09:51 12,633,088 Sqlservr.pdb 01-Nov-2002 18:56 2000.80.698.0 45,644 Sqlvdi.dll 01-Nov-2002 18:00 2000.80.697.0 82,492 Ssnetlib.dll 07-Apr-2002 02:08 2000.80.606.0 70,208 Xplog70.dll 07-Apr-2002 02:08 2000.80.606.0 53,828 Xpqueue.dll 07-Apr-2002 02:08 2000.80.606.0 156,228 Xprepl.dll 12-Jul-2002 01:00 2000.80.658.0 279,104 Xpstar.dll 16-Sep-2002 23:12 2000.80.686.0 98,872 Xpweb70.dllNotes
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in Microsoft SQL Server 2000 Service Pack 4. MORE INFORMATIONHow Hotfix 8.00.0702 reduces contentionHotfix 8.00.0702 introduces a round-robin algorithm for mixed page allocations. With the fix, the starting file will now be different for each consecutive mixed page allocation (if more than one file exists). This avoids the contention problem by breaking up the train that went through the SGAMs in the same order every time with the same starting point. The new allocation algorithm for SGAM is pure round-robin, and does not honor the proportional fill to maintain speed. Microsoft recommends that you create the tempdb data files with the same size.How implementing trace flag -T1118 reduces contentionHere is list of how use of -T1118 reduces contention:
837938 (http://support.microsoft.com/kb/837938/)
You may receive an error message when you try to restore a SQL Server 7.0 database backup on an instance of SQL Server 2000
Increase the number of tempdb data files with equal sizingIf the data file size of tempdb is 5 GB, and the Log file size is 5 GB, the recommendation is to increase the single datafile to 10 (each of 500 MB to maintain equal sizing), and leave the log file as is. Having the different data files on separate disks would be good. However, this is not required and they can co-exist on the same disk.The optimal number of tempdb data files depends on the degree of contention seen in tempdb. As a starting point, you can configure the tempdb to be at least equal to the number of processors assigned for SQL Server. For higher end systems (for example, 16 or 32 proc), the starting number could be 10. If the contention is not reduced, you may have to increase the number of data files more. Note A dual-core processor is considered to be two processors. The equal sizing of data files is critical because the proportional fill algorithm is based on the size of the files. If data files are created with unequal sizes, the proportional fill algorithm tries to use the largest file more for GAM allocations instead of spreading the allocations between all the files, thereby defeating the purpose of creating multiple data files. The auto-grow of tempdb data files can also interfere with the proportional fill algorithm. Therefore, it may be a good idea to turn off the auto-grow feature for the tempdb data files. If the auto-grow option is turned off, you must make sure to create the data files so that they are large enough to prevent the server from experiencing a lack of disk space with tempdb. How increasing the number of tempdb data files with equal sizing reduces contentionHere is a list of how increasing the number of tempdb data files with equal sizing reduces contention:
DisadvantagesThe only downside to the recommendations mentioned earlier is that you may see the size of the databases increase when the following conditions are true:
REFERENCESFor more information about GAM, SGAM, PFS, and IAM, see the following SQL Server 2000 Books Online topics:
APPLIES TO
| Article Translations
|

Back to the top
