TSQL Tutorial

Azure-Pages

Other Blogs

Contents

TempDB memory-optimized metadata

SQL 2019 EXCLUSIVE:

TempDB memory-optimized metadata EXEC sp_configure 'tempdb metadata memory-optimized', 1; RECONFIGURE;

what this setting does and its real-world impact:

What the problem is (before): Every time any session creates a temp table, table variable, or does a sort — SQL Server has to update system metadata tables (sysobjects, sysrowsets etc.) inside TempDB. These tables sit on disk-based data pages, and multiple sessions trying to update them simultaneously fight over page latches. With many concurrent sessions, this becomes a serious bottleneck — sessions queue up one by one, CPU spins in wait loops, and PAGELATCH_EX waits pile up.

What the fix does (after): SQL Server 2019 moves those same system tables into In-Memory OLTP (Hekaton engine). In-memory tables use an optimistic, lock-free, latch-free design — multiple sessions read and write simultaneously with no queuing at all. The contention simply disappears.

Will YOU see a gain? Yes — very likely, because your server has:

  • Many parallel sessions
  • Heavy concurrent workload (417 GB RAM in use)
  • Any stored procedures using temp tables or table variables will benefit immediately

Real-world numbers (from Microsoft benchmarks): on high-concurrency workloads, this single setting reduces TempDB-related waits by up to 40% and can improve overall throughput by 10–30% depending on how temp-table-heavy your queries are.

The only catch — it needs a restart. Plan a maintenance window (off-hours), apply the setting, restart the SQL Server service, and it activates. The restart takes 2–5 minutes typically. After that, run this to confirm it's active:

SELECT SERVERPROPERTY('IsTempDbMetadataMemoryOptimized');

-- Returns 1 if active



No comments:

Post a Comment