Skip to content

SQL Server Wait Type: LCK_M_SCH_M

lck_m_s

The LCK_M_SCH_M wait is an important locking wait to understand in SQL Server.

Wait statistics, in the context of SQL Server, refer to the amount of time that a query spends waiting to access data in the database. When a client application requests data from the database, the request is placed in a queue and the client application must wait for its turn to access the data. The time that the query spends waiting is called a “wait” and is tracked by SQL Server. This information can be used to identify potential performance bottlenecks and optimize the performance of the database. Wait statistics are commonly used by database administrators to diagnose and troubleshoot performance issues in SQL Server.

The LCK_M_SCH_M wait type in SQL Server occurs when a session is waiting to acquire a schema modification (SCH-M) lock on a database object. This lock is required when a process intends to make changes to the structure or schema of an object, such as altering a table or dropping an index. SCH-M locks are exclusive, meaning they prevent other processes from reading or modifying the affected schema while the operation is ongoing. These locks ensure the integrity of schema changes, but they can also create contention if other sessions hold incompatible locks on the same object.

When LCK_M_SCH_M waits are encountered, it often signals a potential bottleneck caused by long-running queries or sessions holding locks on the object in question. For example, a query performing a schema change may be blocked by other sessions that have acquired schema stability (SCH-S) or other conflicting locks for reading or using the object. Troubleshooting these waits involves identifying the blocking session and understanding why it is holding locks for an extended period. Administrators can use tools like sp_whoisactive, sys.dm_tran_locks, or SQL Server Profiler to analyze locking and blocking behavior and take corrective actions such as terminating the blocking session or rescheduling the schema change during off-peak hours.


The LCK_M_SCH_M wait type in SQL Server is a type of wait that occurs when a task is waiting to acquire a schema modification lock. In SQL Server, a schema modification lock is a type of lock that is used to protect the structure of an object, such as a table or index, during certain operations. For example, a schema modification lock might be taken when a query is modifying the structure of an object, or when an index is being created. When a task is in the LCK_M_SCH_M wait state, it is waiting for the schema modification lock to be released before it can continue execution. This wait type is typically only seen when certain operations are being performed on an object in the database.

More details avilable on this wait type here: http://DatabaseHealth.com/Waits/LCK_M_SCH_M.html

LCK_M_SCH_M

Do you have a favorite tool for monitoring your wait statistics on SQL Server over time? This is something that you can use Database Health monitor to do. More details at http://DatabaseHealth.com.

If you are having performance issues assocaited with this wait type and need some help, please contact us with our 30 minute consulation link.

Steve Stedman


More from Stedman Solutions:

SteveStedman5
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!

Leave a Reply

Your email address will not be published. Required fields are marked *