IO_COMPLETION Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related pillar: Storage & Capacity

IO_COMPLETION covers I/O waits that happen outside the normal buffer pool page path. Where PAGEIOLATCH_SH and PAGEIOLATCH_EX track data page reads and writes through the buffer pool, IO_COMPLETION covers most of the I/O that is not a data page: sort spills to tempdb, reads of the transaction log during rollback and recovery, pages read from disk before a database is fully set up, such as during startup, and pages copied into a DBCC snapshot.

The wait type name is generic, which makes it harder to diagnose than the PAGEIOLATCH_* family. The first step is always figuring out what type of I/O is generating the wait.

What it provesA session is waiting on I/O that is not a data page read: a sort spill, a log read, or a page copied into a DBCC snapshot.
What it suggestsOutside maintenance windows, sort spills to tempdb from a memory grant that was too small.
What confirms ittotal_spills above 0 in sys.dm_exec_query_stats for the busy queries, or a DBCC job running in the same window.

What Generates IO_COMPLETION

Sort spills to tempdb, the most common cause in production. When a query does not get enough memory to finish a sort in memory, it spills to tempdb, writing sort runs out and reading them back. Each of those reads and writes is an IO_COMPLETION wait. Unlike PAGEIOLATCH_*, these are not buffer pool pages, so they appear as IO_COMPLETION instead.

Hash spills are not part of it, a spilling hash join or hash aggregate waits on SLEEP_TASK instead. Microsoft’s I/O troubleshooting article lists hash spills under this wait, but on a SQL Server 2025 lab instance a spilling hash join produced 4,561 SLEEP_TASK waits and no IO_COMPLETION, while a spilling sort produced 4,646 IO_COMPLETION waits. If the spilling queries you find are hash operations, start at SLEEP_TASK.

Transaction log reads, reading log blocks back from disk, for example while a transaction rolls back or during crash recovery.

DBCC CHECKDB and DBCC CHECKTABLE, DBCC checks a hidden internal database snapshot, which it creates as sparse files in the same folder as the database’s own data files, not in tempdb. While the check runs, the first change to any page in the source database copies the original page into that snapshot, and the copy shows as IO_COMPLETION. A check that runs while the database is busy will show it. DBCC uses tempdb separately, for its worktables.

Database startup, reading a page from disk before the database is fully set up, for example while it starts up or runs recovery.

Not backups, a backup reads the data files under ASYNC_IO_COMPLETION and writes the backup file under BACKUPIO, so the bulk of a backup window shows in those two waits, not this one.

Bulk operations using row set caches, some bulk insert paths use tempdb staging that goes through IO_COMPLETION rather than the buffer pool.


Is This Wait Expected?

During backup windows, not from the backup itself, because its I/O is counted as BACKUPIO and ASYNC_IO_COMPLETION. If IO_COMPLETION climbs at the same time, look at what else the window runs, such as a DBCC check.

During DBCC runs, yes, when the database is being changed while the check runs, because of the snapshot copies described above.

Outside of maintenance windows, investigate. IO_COMPLETION during production hours usually means sort spills, which means queries are not getting the memory they need (missing indexes or stale stats) or tempdb I/O is slow.


How To Identify The Cause

Check whether a maintenance job is running:

SELECT
    job.name                        AS job_name,
    ja.start_execution_date,
    ja.last_executed_step_date,
    jh.run_status                   AS last_completed_step_status
FROM msdb.dbo.sysjobs job
JOIN msdb.dbo.sysjobactivity ja
    ON ja.job_id = job.job_id
   AND ja.session_id = (SELECT MAX(session_id) FROM msdb.dbo.syssessions)
LEFT JOIN msdb.dbo.sysjobhistory jh
    ON jh.instance_id = ja.job_history_id
WHERE ja.start_execution_date IS NOT NULL
  AND ja.stop_execution_date  IS NULL
ORDER BY ja.start_execution_date DESC;

A running DBCC job lines up with the snapshot copies above. If the running job is a backup, its waits are BACKUPIO and ASYNC_IO_COMPLETION, so look past it for the source of this one.

Find queries that are spilling to tempdb:

SELECT TOP 20
    qs.total_spills / qs.execution_count  AS avg_spills_per_exec,
    qs.total_spills,
    qs.execution_count,
    qs.total_grant_kb / qs.execution_count AS avg_grant_kb,
    qs.total_worker_time / qs.execution_count AS avg_cpu_us,
    SUBSTRING(qt.text, (qs.statement_start_offset / 2) + 1,
        ((CASE qs.statement_end_offset WHEN -1 THEN DATALENGTH(qt.text)
          ELSE qs.statement_end_offset END - qs.statement_start_offset) / 2) + 1) AS statement_text
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
WHERE qs.total_spills > 0
ORDER BY qs.total_spills DESC;
Get-WaitStatistics output in the dba-tools terminal and web UI

Queries with avg_spills_per_exec > 0 are consistently spilling.

Check tempdb I/O specifically, with sys.dm_io_virtual_file_stats:

SELECT
    mf.name                         AS file_name,
    mf.type_desc,
    mf.physical_name,
    vfs.io_stall_write_ms / 1000.0     AS write_stall_sec,
    vfs.io_stall_read_ms  / 1000.0     AS read_stall_sec,
    vfs.num_of_writes,
    vfs.num_of_reads,
    CASE WHEN vfs.num_of_writes > 0
         THEN CAST(vfs.io_stall_write_ms * 1.0 / vfs.num_of_writes AS decimal(10,1))
         ELSE 0
    END AS avg_write_ms,
    CASE WHEN vfs.num_of_reads > 0
         THEN CAST(vfs.io_stall_read_ms * 1.0 / vfs.num_of_reads AS decimal(10,1))
         ELSE 0
    END AS avg_read_ms
FROM sys.dm_io_virtual_file_stats(2, NULL) vfs   -- database_id 2 = tempdb
JOIN sys.master_files mf
    ON mf.database_id = vfs.database_id
    AND mf.file_id    = vfs.file_id
ORDER BY vfs.io_stall_write_ms + vfs.io_stall_read_ms DESC;

High avg_write_ms or avg_read_ms on tempdb data files during production hours, combined with spilling queries, confirms sort spills are the cause.


What To Do

For sort spills (the most common cause):

The root cause is almost always a missing index or stale statistics. A query that spills to disk is doing work it should not need to do.

  1. Identify the spilling queries from dm_exec_query_stats above
  2. Run their execution plans in SSMS with “Include Actual Execution Plan”, look for Sort operators with a yellow warning triangle (“Warnings: Operator used tempdb to spill data”)
  3. Check for missing indexes on the tables involved:

Get Missing Indexes lists the candidates the optimiser already wanted, with example output and what each column means. Copy the T-SQL from that page and run it in SSMS, or run the Get-MissingIndexes wrapper from a clone of dba-tools.

  1. Update statistics on the involved tables
  2. If the query legitimately needs to sort large data sets (e.g. a reporting query), consider whether the result set can be reduced before sorting

For tempdb I/O performance in general:

  • Tempdb data files should be on fast storage, ideally the same SSD/NVMe tier as production data
  • Multiple tempdb data files (one per logical processor, up to 8) reduce allocation contention, though they do not directly improve sort spill I/O

For DBCC-driven IO_COMPLETION:

  • Run DBCC CHECKDB during off-peak hours
  • DBCC CHECKDB with PHYSICAL_ONLY is faster and generates less tempdb I/O (though it checks less)

Where To Go Next

Comments

Leave a Reply

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