December 12, 2024 at 3:37 am
Hi,
Need your help. I've a SP that is using Update statement on a table.
2-3 processes are updating this table at the same time. I'm getting frequent blockage. How can we handle to prevent blockage?
Will using SET XACT_ABORT ON can help?
Or setting to isolation level can help?
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Kindly suggest.
December 12, 2024 at 8:26 am
I'm getting frequent blockage.
What makes you think this?
Will using SET XACT_ABORT ON can help?
Nothing to do with locking.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Will not affect UPDATE locks and potentially dangerous elsewhere.
If you think you have excesive blocking there are plenty of resources. eg
Understand and resolve blocking problems - SQL Server | Microsoft Learn
January 17, 2025 at 7:04 am
Sometimes, re-designing your processes is the best approach.
DBASupport
January 17, 2025 at 1:02 pm
Depending on the update, you may add an index on the field being updated in order that sql server doesn't have to lock the whole table.
update ... where mycol = Y
you may try an index on mycol
usually sql server uses that index to quickly lock on the relevant primary keys
As mentioned by Ken https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/performance/understand-resolve-blocking
January 21, 2025 at 10:33 am
Hi,
Need your help. I've a SP that is using Update statement on a table.
2-3 processes are updating this table at the same time. I'm getting frequent blockage. How can we handle to prevent blockage?
Will using SET XACT_ABORT ON can help?
Or setting to isolation level can help?
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Kindly suggest.
Can you share the blocking xml details?
January 21, 2025 at 10:33 am
Hi,
Need your help. I've a SP that is using Update statement on a table.
2-3 processes are updating this table at the same time. I'm getting frequent blockage. How can we handle to prevent blockage?
Will using SET XACT_ABORT ON can help?
Or setting to isolation level can help?
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Kindly suggest.
Can you share the blocking xml details?
January 21, 2025 at 5:08 pm
I don't have the links for them but I've recently read a few articles that say the turning off page locking for the table did the trick nicely for them. Keep in mind that this is NOT a good idea if the updates affect (for example) tens of thousands of rows in one update. This is for lots and lots of "fast jabs" of just a row or two.
Understand that disabling page locking on a table/index will make it so REORGANIZE cannot be used. Personally, since it frequently perpetuates fragmentation and doesn't work the way most people think it does, I wouldn't use it in any "general purpose" Index Maintenance routines, most of which are also incorrect.
And, I agree with others... the best way to make the UPDATE less resource intensive and faster. Remember that "set based" does NOT mean "all in one query". If you have lots of joins in the UPDATE, you may want to do a little "Divide'n'Conquer". Also remember that your joined updates MUST include the table being updated in the FROM clause and it should have an alias that would be the target of the update. If you don't, then you have an "illegal UPDATE" and you'll never find such an example in the Microsoft documentation. Illegal updates can sporadically loose their minds and take a whole lot longer to do an update of even a single row than you ever thought possible.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy