sys.dm_exec_connections – Day 29 – One DMV a Day

Hello Geeks and welcome to the Day 29 of the long series of One DMV a day. In this series of blogs I will be exploring and explaining the most useful DMVs in SQL Server. As we go ahead in this series we will also talk about the usage, linking between DMVs and some scenarios where these DMVs will be helpful while you are using SQL Server. For the complete list in the series please click here.

Till yesterday I have been writing about the memory related DMVs. Today I am going to start with other set of DMVs which are very useful in performance and other troubleshooting scenarios. I will be starting today with execution related DMVs. The first one will be sys.dm_exec_connections.

Have you ever been asked to check what connections are on the SQL Instance? What protocol are they using? The connection’s address and port number? When did it connected, last read and last written? This is a standard question either someone asks or you need to know when there is an issue reported as a first step. So let us start to see how we can use sys.dm_exec_connections.

SELECT session_id,
FROM sys.dm_exec_connections


Almost all columns in sys.dm_exec_connections is very useful in answering above questions. Let us look at each column description. This will help you while troubleshooting scenarios.


session_id – The session which started this connection. This maps to the session_id in sys.dm_exec_sessions
most_recent_session_id – The session id used for most recent request for this connection.
connection_id – The id of the connection. This is used to map connection to request in sys.dm_exec_requests.
connect_time – Timestamp when the connection is made.
net_transport – The physical transport protocol used to connect.
protocol_type – This is the protocol of the payload on this connection. Currently shows TSQL (TDS) and SOAP protocols.
encrypt_type – Specifies if the connection is encrypted. TRUE or FALSE.
auth_scheme – The authentication mode used for this connection. Windows (KERBEROS/NTLM) or Mixed Mode (SQL).
node_affinity – The Memory node to which this connection has affinity. Refer my SQL OS presentation to understand Memory Nodes and affinity.
num_reads – Number of packet reads made on this connection.
num_write – Number of data packets that are written on this connection.
last_read – Timestamp when the last read occurred on this connection. Maps with the request from most_recent_session_id
last_write – Timestamp when the connection has last written the data packets on the target.
net_packet_size – The network packet size of the data and information transfer on this connection.
client_net_address – Host IP address of the connection.
client_tcp_port – port number associated with this connection on the client.
most_recent_sql_handle – SQL Handle associated with the recent request. This is always in sync with the most_recent_session_id.

The other important information sys.dm_exec_connections exposes is related to MARS (Multiple Active Result Set). MARS was implemented from SQL Server 2005. For every connection made to SQL Server from an application it may need multiple result set. SQL Server simulates MARS by opening a logical connection internally. Multiple requests in a batch interleave and perform their task using this connection. The column parent_connection_id is related to the parent of this logical connection. To learn more about how MARS works refer this link.

This is just a start to the execution related DMVs. To start with I used sys.dm_exec_connections, the most simple of all DMVs in this category. Tomorrow I will be covering another execution related DMV. So, stay tuned. Till then

Happy Learning,

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook |
Follow me on Twitter | Follow me on FaceBook


About Manohar Punna

Manohar Punna is a Microsoft Data Platform Consultant and a Data Platform MVP. In his day to day job he works on building database and BI systems, automation, building monitoring systems, helping customers to make value from their data & explore and learn. By passion Manohar is a blogger, speaker and Vice President of DataPlatformGeeks. He is a community enthusiast and believes strongly in the concept of giving back to the community. Manohar is a speaker at various Data Platform events from SQL Server Day, various user groups, SQLSaturdays, SQLBits, MS Ignite, SSGAS & DPS. His One DMV a Day series is the longest one day series on any topic related to SQL Server available so far.

View all posts by Manohar Punna →

2 Comments on “sys.dm_exec_connections – Day 29 – One DMV a Day”

  1. Your series about DMV’s is very interesting and excellent idea, but I would like to see you elaborate a bit more of every view, not just short comment of attributes. For this DMV for example, to explain the relation between session and connection, the difference between logical and physical connection (parent_connection_id and MARS comes into play) and such stuff. To position the entity you talk about. Show that you really understand what you are talking about, and all the readers will benefit and learn.
    All the best, and keep up the good work!

    1. Thank you Vedran for the advise. I have added additional details to the blog now. Given the scope of concepts like MARS, they cannot be covered in these blogs. But yes, your suggestion is absolutely valid to mention them. Appreciate your time for making these blogs more valuable.

      Thank You,

Leave a Reply

Your email address will not be published.