Düzenle

Aracılığıyla paylaş


sys.dm_pdw_exec_sessions (Transact-SQL)

Applies to: Azure Synapse Analytics Analytics Platform System (PDW)

Holds information about all sessions currently or recently open on the appliance. It lists one row per session.

Note

This syntax is not supported by serverless SQL pool in Azure Synapse Analytics. For serverless SQL pool use sys.dm_exec_sessions.

Column Name Data Type Description Range
session_id nvarchar(32) The ID of the current query or the last query run (if the session is TERMINATED and the query was executing at time of termination). Key for this view. Unique across all sessions in the system.
status nvarchar(10) For current sessions, identifies whether the session is currently active or idle. For past sessions, the session status might show closed or killed (if the session was forcibly closed). ACTIVE, CLOSED, IDLE, TERMINATED
request_id nvarchar(32) The ID of the current query or last query run. Unique across all requests in the system. NULL if none has been run.
security_id varbinary(85) Security ID of the principal running the session.
login_name nvarchar(128) The login name of the principal running the session. Any string conforming to the user naming conventions.
login_time datetime Date and time at which the user logged in and this session was created. Valid datetime before current time.
query_count int Captures the number of queries/requests this session has run since creation. Greater than or equal to 0.
is_transactional bit Captures whether a session is currently within a transaction or not. 0 for auto-commit, 1 for transactional.
client_id nvarchar(255) Captures client information for the session. IPv6 address indicates private endpoint is used. Any valid string.
app_name nvarchar(255) Captures application name information optionally set as part of the connection process. Any valid string.
sql_spid int The IDs column contains closed SPIDs.

For information about the maximum rows retained by this view, see the Metadata section in the Capacity limits topic.

Permissions

Requires the VIEW SERVER STATE permission.

Examples

To find a count of active sessions:

SELECT active_count = COUNT(session_Id)
FROM sys.dm_pdw_exec_sessions
WHERE status = 'ACTIVE';

To find sessions that have been open for longer than 10 minutes:

SELECT *, session_duration_s = DATEDIFF (s, login_time, getdate() ) 
 FROM sys.dm_pdw_exec_sessions
 WHERE DATEDIFF (s, login_time, getdate() ) > 600; -- 10 minutes