nterprise Higher Education systems—such as Ellucian CRM Recruit (Dynamics 365), Ellucian Colleague, and PeopleSoft running on Microsoft SQL Server—frequently experience severe database stalls during high-concurrency events. Events like student admissions surges, registration opening, financial aid disbursement runs, and end-of-term grading generate massive bursts of temporary object creation. When hundreds of concurrent user sessions execute complex queries involving #temp tables, table variables (@table), or large sort/hash spill operations, SQL Server’s central TempDB system database becomes a critical performance bottleneck.
The primary root cause of this performance degradation is latch contention on allocation tracking pages: Page Free Space (PFS), Global Allocation Map (GAM), and Shared Global Allocation Map (SGAM). When hundreds of worker threads simultaneously attempt to allocate or deallocate 8-page extents within a single TempDB datafile, threads stall while waiting to acquire exclusive access to allocation page latches, manifesting as severe PAGELATCH_EX and PAGELATCH_SH wait events.
Architecture & Process Flow
Understanding how TempDB page allocation operates across storage datafiles illustrates why default single-file installations fail under enterprise ERP workloads:
🔍 Diagnostic Checklist & Error Symptoms
When TempDB allocation bottlenecks hit your SQL Server database instance, application users report high response latencies or connection timeouts. Database administrators can confirm TempDB latch contention using the following T-SQL diagnostic queries.
Step 1: Detect PAGELATCH Contention via Waiting Tasks
Query sys.dm_os_waiting_tasks to identify active sessions waiting on TempDB (database_id = 2) allocation pages:
-- Query to identify active TempDB latch contention and resource page numbers
SELECT
wt.session_id,
wt.wait_type,
wt.wait_duration_ms,
wt.blocking_session_id,
wt.resource_description,
er.command,
er.sql_handle
FROM sys.dm_os_waiting_tasks wt
JOIN sys.dm_exec_requests er ON wt.session_id = er.session_id
WHERE wt.wait_type LIKE 'PAGELATCH_%'
AND wt.resource_description LIKE '2:%'; -- Database ID 2 is always TempDB
💡 Tip: A
resource_descriptionformatted as2:1:1indicates database 2 (TempDB), file 1, page 1 (the PFS page). Page2:1:2indicates the GAM page, and2:1:3indicates the SGAM page.
Step 2: Analyze Wait Statistics Aggregates
Verify if PAGELATCH_EX or PAGELATCH_SH dominates total system wait time:
-- Aggregated wait statistics for PAGELATCH wait types
SELECT
wait_type,
waiting_tasks_count,
wait_time_ms,
max_wait_time_ms,
signal_wait_time_ms
FROM sys.dm_os_wait_stats
WHERE wait_type IN ('PAGELATCH_EX', 'PAGELATCH_SH', 'PAGELATCH_UP')
ORDER BY wait_time_ms DESC;
Step-by-Step Resolution Runbook
Resolving TempDB allocation page bottlenecks requires a structured tuning procedure. Every step below must be executed according to best practices to eliminate latch contention.
Step 0: Pre-Flight Safety Checks & Rollback Preparation
Before modifying system configurations or adding datafiles, document current database file locations and file growth parameters:
-- Capture baseline configuration for TempDB datafiles
SELECT
file_id,
name,
physical_name,
(size * 8) / 1024 AS size_mb,
is_percent_growth,
growth AS growth_pages
FROM tempdb.sys.database_files;
Step 1: Configure Multiple Equal-Sized TempDB Datafiles
The most effective fix for PFS/GAM page contention is splitting TempDB into multiple datafiles of identical initial size and autogrowth settings. This enables SQL Server’s proportional fill algorithm and round-robin allocation to distribute allocation page latches evenly across files.
- Rule of Thumb: Configure 1 datafile per logical CPU core up to 8 datafiles. If cores exceed 8, start with 8 datafiles and add in blocks of 4 only if contention persists.
Execute the following T-SQL to add equal-sized datafiles:
-- Step 1: Modify existing primary file size and autogrowth
ALTER DATABASE [tempdb]
MODIFY FILE ( NAME = N'tempdev', SIZE = 8192MB , FILEGROWTH = 1024MB );
GO
-- Step 2: Add additional equal-sized files (Example for 4-file setup)
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev2', FILENAME = N'T:\TempDB\tempdev2.ndf' , SIZE = 8192MB , FILEGROWTH = 1024MB );
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev3', FILENAME = N'T:\TempDB\tempdev3.ndf' , SIZE = 8192MB , FILEGROWTH = 1024MB );
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev4', FILENAME = N'T:\TempDB\tempdev4.ndf' , SIZE = 8192MB , FILEGROWTH = 1024MB );
GO
🚨 Warning: All TempDB datafiles MUST have identical initial sizes and autogrowth increments. If one file grows larger than others, proportional fill will route all new allocations to that single file, re-introducing latch contention!
Step 2: Enforce Trace Flags 1117 & 1118 (SQL Server 2014 and Earlier)
On legacy SQL Server versions (2014 and prior), enable Trace Flags 1117 (grow all files in a filegroup simultaneously) and 1118 (force uniform extent allocations, bypassing mixed extents and SGAM pages).
- SQL Server 2016+: Trace Flags 1117 and 1118 are enabled by default for TempDB and cannot be disabled.
- SQL Server 2014 and older: Enable trace flags globally via SQL Server Configuration Manager startup parameters
-T1117and-T1118, or execute:
-- Enable trace flags globally (requires sysadmin)
DBCC TRACEON (1117, 1118, -1);
GO
Step 3: Enable Memory-Optimized TempDB Metadata (SQL Server 2019+)
In SQL Server 2019 and 2022, system table metadata contention for temporary tables (contention on catalog tables like sysobjvalues and sysschobjs) can be completely eliminated by converting TempDB metadata management into In-Memory OLTP memory-optimized tables.
Enable Memory-Optimized TempDB Metadata via sp_configure:
-- Enable Memory-Optimized TempDB Metadata (Requires SQL Server Restart)
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
EXEC sp_configure 'tempdb metadata memory-optimized', 1;
RECONFIGURE;
GO
🚨 Warning: Enabling Memory-Optimized TempDB Metadata requires an instance restart. Test thoroughly in non-production environments as certain features (such as
COLUMNSTOREindexes on#temptables) have specific limitations when this feature is active.
📚 Official Documentation & Technical References
- Recommendations to reduce allocation contention in SQL Server tempdb database — Microsoft Learn Documentation
- TempDB Database Overview & Best Practices — Microsoft Learn Documentation
- sys.dm_os_waiting_tasks (Transact-SQL) — Microsoft Learn Documentation
- DBCC TRACEON - Trace Flags (Transact-SQL) — Microsoft Learn Documentation
Need assistance optimizing your SQL Server database instance or resolving TempDB allocation bottlenecks for enterprise ERP applications? Contact our Infrastructure Specialists or explore our Enterprise Health Audits.