Download - SQL Server ASYNC_NETWORK_IO Wait Type Explained

Transcript
Page 1: SQL Server ASYNC_NETWORK_IO Wait Type Explained

SQL Server Performance Tuning for ASYNC_NETWORK_IO

Dean Richards

Senior DBA

Confio Software

8/27/2013 1

Page 2: SQL Server ASYNC_NETWORK_IO Wait Type Explained

About ASYNC_NETWORK_IO

• ASYNC_NETWORK_IO (2005/2008/2012)

• NETWORKIO (2000)

• Typically indicates a network-related or client application issue

• May require modifications to client application to resolve

8/27/2013 2

Page 3: SQL Server ASYNC_NETWORK_IO Wait Type Explained

What causes ASYNC_NETWORK_IO waits?

• Client applications process rows one at a time using fetches

• If serving up many rows, this causes server process to wait

• If the server process waits, this fills network buffers

• If network buffers fill, SQL Server can’t send more data to the client

• The process executing the batch must wait before continuing to send results to the client

• And all this results in ASYNC_NETWORK_IO waits

8/27/2013 3

Page 4: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Where to start tuning

• When you see ASYNC_NETWORK_IO waits, the issue is outside the database

• Start by reviewing client applications

• Look for ways to improve data retrieval for client application (or middle tier, if a Web application)

8/27/2013 4

Page 5: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Common cause: applications that ask for large result sets

• Some applications (like MS Access) request large results sets, and then filter the data on the client

• Look for ways to reduce size of results sets

• Try creating a view for the client application – Ensures all filtering is done on SQL Server

– May significantly reduce amount of data being pushed to the client

• Try adding a WHERE clause or further restrict the query in some way

8/27/2013 5

Page 6: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Common cause: applications that ask for large result sets (continued)

• Try to work with the developer or application team to understand: – How is result set being consumed?

– Are all the rows being used?

• If the application querying large results sets is using only a few rows, try to: – Modify the query to get just the rows that are

needed

– Use ‘TOP n’ to reduce the number of rows returned

8/27/2013 6

Page 7: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Common cause: applications that ask for large result sets (continued)

• If encountering high ASYNC_NETWORK_IO waits when performing data loads on server, make sure:

– Shared memory protocol is enabled for the instance

– Session is connected using net_transport=‘Shared memory’

• Look at the DMV - sys.dm_exec_connections to determine the net_transport for the connection

8/27/2013 7

Page 8: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Common network-related caused of ASYNC_NETWORK_IO

• Review counters such as 'Batch Requests per second' – Values > 3000 for a 100MB network card are excessive – Values > 0.6 for 'Current Bandwidth' on the Network

Interface are excessive

• Check network adapter bandwidth – 1 Gigabit is better than 100 megabits ,and 100 megabits is

better than 10 megabits

• Review NIC configuration on the server – Check that there are no issues with the physical card – Check if AUTODETECT is picking the fastest speed

• Validate all network components between the client application and the SQL Server instance – For example, check all the switches, routers and so on

8/27/2013 8

Page 9: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Review Resource Usage

• Query DMVs to review the resources SQL Server sessions are waiting on

• To view sql text, wait type and time waited, run this query:

SELECT st.text AS [SQL Text],

w.session_id,

w.wait_duration_ms,

w.wait_type, w.resource_address,

w.blocking_session_id,

w.resource_description FROM sys.dm_os_waiting_tasks AS w

INNER JOIN sys.dm_exec_connections AS c ON w.session_id = c.session_id

CROSS APPLY (SELECT * FROM sys.dm_exec_sql_text(c.most_recent_sql_handle))

AS st WHERE w.session_id > 50

AND w.wait_duration_ms > 0

• The 'wait_duration_ms' value will increase for the session_id as the session is waiting for the 'wait_type' (for a specific SQL)

8/27/2013 9

Page 10: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Performance Tuning Tip

• Record results of the DMV queries over time

– Get clear picture of all SQLs and what resources (or wait types) they are waiting on

– Understand where the real issues are

• To reset the wait statistics in the DMVs, enter the following command in SSMS:

DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)

8/27/2013 10

Page 11: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Learn more about SQL Server Tuning

• Go to confio.com/logicalread • Free performance tuning tips for SQL Server,

including:

– Waits and queues tuning method (also known as response time analysis)

– Tips on tuning for specific wait types

– Indexing strategies that can improve performance

– Much more, from industry experts and SQL Server MVPs

8/27/2013 11

Page 12: SQL Server ASYNC_NETWORK_IO Wait Type Explained

Finally, Confio Ignite Can Help, Too

• Confio Ignite identifies queries with large amounts of ASYNC_NETWORK_IO waits and many other database performance issues

• Installs in minutes

• Finds issues in 5 clicks or less

Download Ignite trial at

www.confio.com/freetrial

8/27/2013 12