PREEMPTIVE_OS_QUERYREGISTRY Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: SOS_SCHEDULER_YIELD Wait TypeRelated pillar: Performance & Troubleshooting
⚡PREEMPTIVE_OS_QUERYREGISTRY is SQL Server reading the Windows registry. Normally trivial, but a known SQL Server 2022 bug made it a contention point, fixed in 2022 CU5. Run the check to see your build and who is reading the registry.

Microsoft lists it as internal use only. It is the generic wait for Windows registry functions. While the call runs, the thread is in preemptive mode, outside SQL Server’s scheduler. Procedures such as xp_regread and xp_instance_regread read the registry, and so do some configuration lookups.


Is It a Problem?

Usually not; on our SQL Server 2025 lab it had about 55,000 waits averaging under a millisecond in a day. Get Wait Statistics does not filter it out, so if it ranks, you will see it. The exception is the SQL Server 2022 bug, fixed in CU5: on 2022 below CU5, a high ranking is a patch question before anything else. Otherwise a high count usually comes from monitoring or audit scripts calling the registry procedures often.

The baseline to monitor is its average wait per call over an interval rather than the cumulative totals.


Common Causes

  • The SQL Server 2022 bug, before CU5.
  • Monitoring or audit scripts calling xp_regread or xp_instance_regread at a high rate.
  • Normal configuration reads, in small amounts.

The Check To Run

Rank it against everything else with Get Wait Statistics, then check the build:

SELECT
    SERVERPROPERTY('ProductVersion') AS product_version,
    SERVERPROPERTY('ProductLevel') AS product_level,
    SERVERPROPERTY('ProductUpdateLevel') AS update_level;

SQL Server Builds maps the version to its cumulative update. While the wait is happening, catch the caller:

SELECT
    r.session_id,
    r.wait_type,
    r.wait_time AS wait_ms,
    s.login_name,
    s.program_name,
    t.text AS running_sql
FROM sys.dm_exec_requests AS r
JOIN sys.dm_exec_sessions AS s ON s.session_id = r.session_id
OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE r.wait_type LIKE N'PREEMPTIVE_OS_QUERYREGISTRY'
ORDER BY r.wait_time DESC;

The caller query needs VIEW SERVER STATE.


What To Do

  1. On SQL Server 2022, apply CU5 or later.
  2. Otherwise, find the scripts or tools reading the registry and reduce how often they do.
  3. If individual registry reads are slow, that points at the operating system, which is a separate investigation.

The PREEMPTIVE_OS Call Waits

Each of these is SQL Server calling a Windows function outside the file and security groups: networking, pipes, the registry, the event log, DLLs and the cluster. The time is spent in Windows. If one is near the top of your waits, read it next to the waits that usually matter.

  • Network waitsDNS and sockets. GETADDRINFO name lookups and Winsock calls; slow DNS shows here.Worth a look when it climbs
  • PREEMPTIVE_OS_PIPEOPSPipes. Windows pipe functions, such as xp_cmdshell reading its command output.Worth a look when it climbs
  • PREEMPTIVE_OS_WAITFORSINGLEOBJECTClient sync. Synchronising with an external client process; often seen with ASYNC_NETWORK_IO.Worth a look when it climbs
  • PREEMPTIVE_OS_QUERYREGISTRYRegistry. Windows registry functions.Worth a look when it climbs. This page.
  • PREEMPTIVE_OS_REPORTEVENTEvent log. The Windows ReportEvent function, writing to the event log.Worth a look when it climbs
  • PREEMPTIVE_OS_GETPROCADDRESSXP entry points. Finding an extended stored procedure’s address in its DLL.Worth a look when it climbs
  • Library waitsDLL loading. Loading and unloading DLLs in the SQL Server process.Usually noise
  • Cluster waitsFailover cluster. Windows failover cluster API calls.Usually noise
  • Miscellaneous waitsEverything else. The remaining single-call waits, such as VSS, FILESTREAM device and service calls.Worth a look when it climbs

Where To Go Next

If PREEMPTIVE_OS_QUERYREGISTRY is ranking high, these are the next places to look.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *