Retrieving the database user for a request exposed by the sys.dm_pdw_exec_requests DMV

pmscorca 1,032 Reputation points
2024-03-13T18:41:35.79+00:00

Hi,

during a monitoring activity for a Synapse dedicated SQL pool using the sys.dm_pdw_exec_requests DMV I've noticed an unexpected resource class and so I need to retrieve the corresponding database user.

The sys.dm_pdw_exec_requests DMV esposes some data which request_id, session_id, total_elapsed_time, resource_class, group_name and classifier_name, but not an useful id to retrieve the related database user.

Any suggests to me, please?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,243 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VINODH KUMAR 30,031 Reputation points MVP
    2024-03-14T07:44:03.84+00:00

    Hi pmscorca,

    Thanks for reaching out to Microsoft Q&A.

    You can by joining the 'sys.dm_pdw_exec_requests' view with the 'sys.dm_pdw_exec_sessions' view using the session_id column. This will let you link the request_id to the session under which it was executed.

    Go ahead and select the relevant columns from both views. Specifically, you will need the session_id (associated with the session), the command (which holds the full text of the request submitted by the user), and any other relevant information. Or you can simply use the following query to pull the active or running connections with the database user_id.

    SELECT
        r.session_id,
        s.login_name AS 'User ID',
        r.command
    FROM sys.dm_pdw_exec_requests AS r
    JOIN sys.dm_pdw_exec_sessions AS s ON r.session_id = s.session_id
    WHERE r.status NOT IN ('Completed', 'Failed', 'Cancelled')
    

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.