Sei sulla pagina 1di 2

HaveyoueverbeenaskedtocheckwhatconnectionsareontheSQLInstance?Whatprotocolaretheyusing?

Theconnectionsaddressandportnumber?Whendiditconnected,lastreadandlastwritten?Thisisa
standardquestioneithersomeoneasksoryouneedtoknowwhenthereisanissuereportedasafirststep.So
letusstarttoseehowwecanusesys.dm_exec_connections.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

SELECTsession_id,

most_recent_session_id,

connection_id,

connect_time,

net_transport,

protocol_type,

encrypt_option,

auth_scheme,

node_affinity,

num_reads,

num_writes,

last_read,

last_write,

net_packet_size,

client_net_address,

client_tcp_port,

most_recent_sql_handle
FROMsys.dm_exec_connections

Almostallcolumnsinsys.dm_exec_connectionsisveryusefulinansweringabovequestions.Letuslookat
eachcolumndescription.Thiswillhelpyouwhiletroubleshootingscenarios.
session_idThesessionwhichstartedthisconnection.Thismapstothesession_idin
sys.dm_exec_sessions
most_recent_session_idThesessionidusedformostrecentrequestforthisconnection.
connection_idTheidoftheconnection.Thisisusedtomapconnectiontorequestin
sys.dm_exec_requests.
connect_timeTimestampwhentheconnectionismade.
net_transportThephysicaltransportprotocolusedtoconnect.
protocol_typeThisistheprotocolofthepayloadonthisconnection.CurrentlyshowsTSQL(TDS)and
SOAPprotocols.
encrypt_typeSpecifiesiftheconnectionisencrypted.TRUEorFALSE.
auth_schemeTheauthenticationmodeusedforthisconnection.Windows(KERBEROS/NTLM)orMixed
Mode(SQL).
node_affinityTheMemorynodetowhichthisconnectionhasaffinity.RefermySQLOSpresentationto
understandMemoryNodesandaffinity.
num_readsNumberofpacketreadsmadeonthisconnection.
num_writeNumberofdatapacketsthatarewrittenonthisconnection.
last_readTimestampwhenthelastreadoccurredonthisconnection.Mapswiththerequestfrom
most_recent_session_id
last_writeTimestampwhentheconnectionhaslastwrittenthedatapacketsonthetarget.
net_packet_sizeThenetworkpacketsizeofthedataandinformationtransferonthisconnection.
client_net_addressHostIPaddressoftheconnection.
client_tcp_portportnumberassociatedwiththisconnectionontheclient.
most_recent_sql_handleSQLHandleassociatedwiththerecentrequest.Thisisalwaysinsyncwiththe
most_recent_session_id.
Theotherimportantinformationsys.dm_exec_connectionsexposesisrelatedtoMARS(MultipleActiveResult
Set).MARSwasimplementedfromSQLServer2005.ForeveryconnectionmadetoSQLServerfroman
applicationitmayneedmultipleresultset.SQLServersimulatesMARSbyopeningalogicalconnection
internally.Multiplerequestsinabatchinterleaveandperformtheirtaskusingthisconnection.Thecolumn
parent_connection_idisrelatedtotheparentofthislogicalconnection.TolearnmoreabouthowMARS
worksreferthislink.

Potrebbero piacerti anche