PAGELATCH_UP

The PAGELATCH_UP wait type in SQL Server indicates that a thread is waiting to acquire an update latch on a data page in memory. This latch ensures that no other thread modifies the page while it is being updated. However, the page is not being read from or written to disk, as this type of latch is related to in-memory data page contention.

Here’s a more detailed breakdown:

What Causes PAGELATCH_UP Waits?

  • High concurrency: Multiple threads (queries) attempting to update or modify the same page at the same time.
  • Hot spots: Certain database objects, like indexes or tables, become hot spots when they are frequently accessed for updates, especially on specific pages like the first page of an index (common in tables with monotonically increasing keys).
  • Contention on allocation pages: Pages like PFS (Page Free Space) or GAM (Global Allocation Map) can experience high contention, leading to PAGELATCH_UP waits.

Where Does PAGELATCH_UP Typically Occur?

  • Index Updates: If you have a frequently updated index with a monotonically increasing key (such as an identity column), the first page of that index might become a bottleneck.
  • Heap Inserts: High-volume inserts into a heap table (without a clustered index) can cause latching contention.
  • Allocation Structures: Contention on special system pages like PFS, GAM, or SGAM can lead to these waits, especially during high-volume inserts or updates.

How to Identify PAGELATCH_UP Waits?

You can monitor PAGELATCH_UP waits by querying system DMVs like:

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 = 'PAGELATCH_UP';

Additionally, you can dig deeper to see what pages are being affected by the wait using this query:

SELECT 
    r.session_id, 
    r.wait_type, 
    r.resource_description, 
    r.wait_time, 
    r.blocking_session_id
FROM sys.dm_exec_requests r
WHERE r.wait_type = 'PAGELATCH_UP';

The resource_description column will show you the specific page ID and database where the contention is happening.

Mitigating PAGELATCH_UP Waits

  1. Optimize Index Design: Avoid indexes with sequential keys (like identity or sequential GUIDs) to distribute inserts across a wider range of pages.
  2. Consider Partitioning: If contention is happening on a specific table or index, partitioning it can help distribute the load across different pages.
  3. Use a Different Fill Factor: Adjusting the fill factor on heavily updated indexes can reduce contention by leaving more free space on the pages.
  4. Reduce Contention on Allocation Pages: For heap tables experiencing high inserts, adding a clustered index can alleviate contention on allocation pages like PFS and GAM.

By keeping an eye on PAGELATCH_UP waits and addressing hot spots, you can significantly improve the performance of your SQL Server instance.

If you’re struggling with PAGELATCH_UP or other SQL Server performance issues, our SQL Server Managed Services at Stedman Solutions are designed to help with deep performance tuning and long-term monitoring using tools like Database Health Monitor.