Sql-server – Why does a query on a local instance with local database files cause NETWORK_IO waits

extended-eventsNetworksql serversql-server-2012wait-types

I have followed this tutorial to get the wait stats of a particular query while it is 'in flight' using extended events. Whilst the tutorial refers to an index rebuild, I just did a select statement from a single table

The waits (using the query in the tutorial) were

Wait Type            Wait Count  Wait Time  Resource Wait Time  Signal Wait Time
-------------------  ----------  ---------  ------------------  ----------------
NETWORK_IO                  693        778                 776                 2
SOS_SCHEDULER_YIELD           6          0                   0                 0

I ran the query in SSMS on the same box the instance is installed on (used . as my server name when connecting)
the data files for the database are on the C:/ drive of the box so I am confused as to why NETWORK_IO is showing?

As a further test, I disabled the network adapter on the box and found the same result (obviously with slightly different numbers)

Would I be right in thinking that NETWORK_IO relates to SQL server returning the result to SSMS?

Best Answer

Usually this surfaces as ASYNC_NETWORK_IO outside of Extended Events, but yes, it is the time SQL Server spent waiting for the caller (in this case SSMS) to consume the results. If the caller is slow (like SSMS) then SQL Server has to sit there and wait before feeding more rows. If you have a wide result set or large values, you should compare results to grid and results to text. But really, you shouldn't be timing anything based on response times in SSMS, since it does unrealistic things with the data and how it renders that your application won't be doing (hopefully).

I wrote about this wait type (and 9 other common ones) here: