Using sys.dm_exec_requests to Troubleshoot Blocking
By Tom Nonmacher
SQL Server provides a wealth of dynamic management views (DMVs) that can be leveraged to troubleshoot a variety of issues. One of the most useful for investigating blocking issues is sys.dm_exec_requests. This DMV returns information about all requests that are currently executing in SQL Server. In this post, we'll delve into how to use sys.dm_exec_requests to identify and resolve blocking issues in SQL Server 2016 and 2017, MySQL 5.7, DB2 11.1, and Azure SQL.
The sys.dm_exec_requests DMV includes a column called blocking_session_id. This column will display the session ID of the blocking transaction if a request is being blocked, or 0 if it is not. To get a quick view of any current blocking situations, you can run the following T-SQL query in SQL Server Management Studio:
SELECT session_id, blocking_session_id, wait_time, wait_type, wait_resource
FROM sys.dm_exec_requests
WHERE blocking_session_id != 0;
Unfortunately, MySQL doesn't have an equivalent DMV to sys.dm_exec_requests. However, you can get similar information by querying the INFORMATION_SCHEMA.PROCESSLIST table. Here's an equivalent MySQL query to find blocking issues:
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE COMMAND = 'Sleep' AND TIME > 200;
For DB2 11.1, you can gather similar information from the MONITOR functions. Here's a sample DB2 query to find blocking issues:
SELECT APPLICATION_HANDLE, LOCK_WAIT_TIME, LOCK_WAIT_STATUS
FROM TABLE(MON_GET_CONNECTION(NULL, -2)) AS t
WHERE LOCK_WAIT_TIME > 0;
Azure SQL Database, being a fully managed version of SQL Server, also supports sys.dm_exec_requests. You can use the same T-SQL query as for SQL Server 2016 and 2017 to find blocking issues in Azure SQL Database.
It's worth mentioning that these simple queries only provide an initial indication of a possible problem. They don't show the complete picture and won't always accurately identify the root cause of a blocking issue. However, they're a good first step in diagnosing blocking issues in your database.
In conclusion, sys.dm_exec_requests and its equivalents in other databases are powerful tools for identifying blocking issues. With a bit of understanding and some simple queries, you can use them to quickly identify and resolve blocking issues in SQL Server 2016 and 2017, MySQL 5.7, DB2 11.1, and Azure SQL.
Check out the latest articles from all our sites:
- How to Take Advantage of Flash Sales at Grocery Stores [https://www.ethrift.net]
- A brief history of the Galveston Hurricane of 1900 [https://www.galvestonbeachy.com]
- How to Plant and Maintain Chokeberry Bushes [https://www.gardenhomes.org]
- New Query Store Enhancements in SQL Server 2022 [https://www.sqlsupport.org]
- Heat: Why My Laptop Is Cooking My Lap [https://www.SupportMyPC.com]
- The Best Months to Visit South Korea for Cherry Blossoms and Fall Colors [https://www.treasureholidays.com]
Privacy Policy for sqlsupport.org
Last updated: Feb 03, 2026
sqlsupport.org respects your privacy and is committed to protecting any personal information you may provide while using this website.
This Privacy Policy document outlines the types of information that are collected and recorded by sqlsupport.org and how we use it.
Information We Collect
- Internet Protocol (IP) addresses
- Browser type and version
- Pages visited
- Time and date of visits
- Referring URLs
- Device type
Cookies and Web Beacons
sqlsupport.org uses cookies to store information about visitors preferences and to optimize the users experience.
How We Use Your Information
- Operate and maintain our website
- Improve user experience
- Analyze traffic patterns
- Prevent fraudulent activity
Contact
Email: admin@sqlsupport.org