Hi @Mounika Vemula ,
Please let me know what does that mean?
It means a partition below the table is locked.
hobt_id: Indicates the ID of the data heap or B-tree (HoBT) that contains the rows for this partition.
Does it give me more details about where the lock exists and what can i do to fix it ?
You have already get the index_id and table name.
You have to optimize your table design.If this index is not necessary, please delete it.
And you can also reference resolutions from this doc.: sql-server-wait-type-lck-m-u
Please advise. How can we avoid this.
For your case: You have to optimize your table design.If this index is not necessary, please delete it.
tips:
Minimize unnecessary indexes. The greater the number of indexes, the more locks may be required.
But also strictly avoid the occurrence of table scans. If you only modify a small part of the table records, try to use Index Seek to avoid the execution plan of the full table scan.
for select:
(In a non-"uncommitted read" isolation level).
(1) When the query is running, a shared lock will be added to each read record or key value. If the record does not need to be returned, the lock will be released. If the record needs to be returned, it depends on the isolation level. If it is "committed to read", it is also released, otherwise it is not released.
(2) For each index used, SQL Server will also add a shared lock to the above key value.
(3) For each page read, SQL Server will add an intention lock.
(4) The more pages and records that the query needs to scan, the more the number of locks will be. The more indexes used in the query, the greater the number of locks.
So,if you want to reduce the probability of a select query being blocked by others or blocking others, database designers can do:
(1) Try to return as few records as possible. The more results returned, the more locks are needed.
(2) If the returned result set is only a small part of all the records in the table, try to use Index Seek to avoid the execution plan of full table scan.
(3) If possible, design an appropriate index. Avoid SQL Server to find data through multiple indexes.
Of course, these are all for the isolation level above "committed read". If you choose "Uncommitted Read", SQL Server will not apply for these shared locks, and blocking will not occur.
for update:
(1) For each index used, SQL Server will add a U lock to the above key value.
(2) SQL Server only adds X locks to the records or key values to be modified.
(3) The more indexes used to modify the column, the greater the number of locks.
(4) The more pages scanned, the more intention locks will be. During the scanning process, all scanned records will be locked, even if the above is not modified.
So,if you want to reduce the probability of an UPDATE being blocked by others, in addition to paying attention to its query part, the database designer should also do:
(1) Modify as few record sets as possible. The more records are modified, the more locks are required.
(2) Minimize unnecessary indexes. The greater the number of indexes, the more locks may be required.
(3) But also strictly avoid the occurrence of table scans. If you only modify a small part of the table records, try to use Index Seek to avoid the execution plan of the full table scan.
BR,
Mia
If the answer is helpful, please click "Accept Answer" and upvote it.