MSQL_XP is recorded while a task waits for an extended stored procedure (XP) to finish. Extended stored procedures are external code, DLLs loaded into the SQL Server process, called through the old XP interface: xp_cmdshell, xp_fixeddrives, third-party backup and monitoring XPs, and vendor add-ons. The wait lasts exactly as long as the external code runs, and it is preemptive, so the thread stays under Windows control until the XP returns.
The wait tells you nothing about why the XP is slow, only that SQL Server is sitting inside external code.
Is It a Problem?
The wait is honest bookkeeping; the concern is what it measures. Large MSQL_XP accumulations mean significant time inside code the engine cannot see into or schedule around. A hung XP is worse than a slow query: it pins a worker thread indefinitely, and troubleshooting options from inside SQL Server are limited.
Third-party XPs from backup tools and monitoring agents are the usual heavyweights, and old in-process DLLs are also a stability risk to the whole instance.
Common Causes
xp_cmdshelland friends doing slow external work.- Third-party backup or monitoring products implemented as XPs taking their time (or hanging) inside the SQL process.
- Legacy vendor integrations calling custom XP DLLs.
- A wedged external dependency, a dead network target or stuck child process, holding the XP open.
What To Do
- Identify which XPs run and from where: catch sessions in this wait via
sys.dm_exec_requestsand capture the calling SQL text. - Time-box and monitor the external work the XP performs; a hung XP usually traces to a hung external dependency.
- Modernise where possible. CLR integration, Agent job steps, or application-side services replace most legacy XP use cases without loading foreign DLLs into the engine’s address space.
- For third-party XPs, take the evidence (wait times, thread dumps if needed) to the vendor; that code is theirs to fix.
How To See It
Rank it against everything else with Get-WaitStatistics. If MSQL_XP ranks highly, inventory every extended stored procedure in use before tuning anything else.
Part of the SQL Server Wait Types Library.
Related deep dive: ASYNC_NETWORK_IO Wait Type.
Leave a Reply