Haripriya Naidu is trying to slam a lot of transactions through the same door:
When operations wait to acquire a latch on a page, you’ll see a wait type called PAGELATCH
. A latch is a lightweight lock. PAGELATCH
waits typically occur in TempDB on pages like PFS, GAM, SGAM, or system object pages.
Normally, you won’t see PAGELATCH
waits in user databases because user objects don’t usually experience the same level of concurrent inserts/updates/deletes as temp tables do.
But, there is one case where this can happen:
When many concurrent transactions try to insert into the last page of a table, they all compete for a latch on that page. This results in last page insert contention.
Read on to see when this happens, as well as a demonstration of it. Haripriya then uses a bit of functionality that is available in recent versions of SQL Server to resolve the issue.