May 24, 2006 at 12:52 pm
Hi
I am having issues when the same SQL queries run simultaneously from diiferent ASP App threads is getting deadlocked.
The deadlock is for a query, which calls a Stored Proc. The stored Proc has a transaction, inside of which it does the following
Alter Proc DoSomething
BEING
BEGIN TRANSACTION TRAN1
SELECT * from TABLEA -- captures values in local variables
DELETE from TABLEA
INSERT into TABLEB -- values captured from TABLEA
COMMIT TRANSACTION TRAN1
SELECT @V1, @V2 from TABLEA -- same as in first step
END
It is the DELETE that is causing a Deadlock
Would really appreciate help on this
Thanks
Alvin
May 24, 2006 at 2:21 pm
How many rows does your SELECT and DELETE statement process? You need to check your execution plans for these 2 statements. My guess is that the execution plan will not show index seek / indexed delete.
Deadlocks can happen when more than one thread is accessing the same tables, but you should be able to greatly minimize this by keeping your transactions as short as possible. Part of keeping your transactions as short as possible is proper index design and use of indexes.
May 24, 2006 at 2:53 pm
This is affecting 7800 rows. Index is being used where it can, for example delete is based on that.
Thanks
May 25, 2006 at 9:06 am
Another possible method to shorten the transaction is to:
INSERT INTO TableB SELECT..FROM TableA
DELETE FROM TableA INNER JOIN TableB ON...
Assuming that indices are available for the SELECT and DELETE..JOIN
May 27, 2006 at 11:35 pm
Since you don't use XACT_Abort and you don't have any error checking code to do a conditional rollback, you don't really need the transaction.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 2, 2006 at 10:30 am
Even if do a transaction abort, that wouldn't do anything, since the transaction does rollback. Thanks
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply