﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / Avoid DEADLOCK for concurrent DELETE / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 03:39:48 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>recommendations:1) see here:http://blogs.msdn.com/bartd/archive/2006/09/09/Deadlock-Troubleshooting_2C00_-Part-1.aspxNote there are 2 additional parts to this blog series.  2) as someone else said, you will likely need to batch up the DELETE.  3) you might also need a NC index on the date you are using for one of the deletes.4) get a professional on board to help you.  That sounds like a very complicated process and you might need some difficult refactoring to get everything to play nicely.</description><pubDate>Wed, 27 Feb 2013 06:20:24 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>Hello,maybe you can try to delete rows in small blocks, replacing your DELETE instruction by something like (I cannot check the syntax now)[code="sql"]Delete TOP 1000 Products where instance = 'XXXX-xxx-xxx-xx'WHILE @@rowcount &amp;gt; 0    Delete TOP 1000 Products where instance = 'XXXX-xxx-xxx-xx'[/code]It should help you to minimize deadlocks.Regards,    Francesc</description><pubDate>Tue, 26 Feb 2013 05:22:43 GMT</pubDate><dc:creator>frfernan</dc:creator></item><item><title>RE: Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>[quote][b]VASUforSQL (2/25/2013)[/b][hr]Hi ALL,I have a table called Products which has many columns.It is a temporary table used for reporting purpose. The data will be processed to this table concurrently by multiple user requests.(seperate Stored procedure to make DML operations to this table)....And instance column have the newid() value. one user request will have one unique id; may have million rows. ...[/quote]Instead of forcing all users to share a single huge dynamic "temporary" table with all of the hardship you are currently facing, why not give them one each, with none?</description><pubDate>Tue, 26 Feb 2013 03:42:06 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>HI I tried with Snapshot. It still raising DEADLOCK issue. and some records are not getting updated properly. Please suggest:1. Isolation Level2. Locks for DELETE statments</description><pubDate>Tue, 26 Feb 2013 02:27:34 GMT</pubDate><dc:creator>VASUforSQL</dc:creator></item><item><title>RE: Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>[quote][b]VASUforSQL (2/25/2013)[/b][hr]Hi ALL,I have a table called Products which has many columns.It is a temporary table used for reporting purpose. The data will be processed to this table concurrently by multiple user requests.(seperate Stored procedure to make DML operations to this table)Table Structure: Create table Products (instance uniqueidentifier, inserted datetime, col1, col2,...)Inserted column will be populated with GETDATE() to have when the data are inserted. And instance column have the newid() value. one user request will have one unique id; may have million rows. The below are the queries which will be executed concurrently, which causing the deadlock. Please advise meQuery1: "Set transaction isolation readuncommitted Delete P from Products (Nolock) where instance = 'XXXX-xxx-xxx-xx'"Query2: "Set transaction isolation readuncommitted Delete P from Products (Nolock) where inserted&amp;lt;=DATEADD(hh, -10, getdate())"Note: The nonclustered index is created on instance column.PLEASE ADVISE me which lock I can use in this scenario.Note I couldnt able to primary key as it is consuming time when I insert 10 million rows to the table (this for one transaction; there are 20 concurrent transations). The report should be generated sooner. And my procedure has multiple 35 DML statments, there are around 15 DELETE statements for instance column with other columns( DElete from table where instance = @instance and col1 = @col1)[/quote]You should look into isolation instead of locking. Snapshot isolation sounds like it would be a good fit. [url=http://msdn.microsoft.com/en-us/library/ms173763.aspx]http://msdn.microsoft.com/en-us/library/ms173763.aspx[/url]</description><pubDate>Mon, 25 Feb 2013 12:13:11 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>Avoid DEADLOCK for concurrent DELETE</title><link>http://www.sqlservercentral.com/Forums/Topic1423714-146-1.aspx</link><description>Hi ALL,I have a table called Products which has many columns.It is a temporary table used for reporting purpose. The data will be processed to this table concurrently by multiple user requests.(seperate Stored procedure to make DML operations to this table)Table Structure: Create table Products (instance uniqueidentifier, inserted datetime, col1, col2,...)Inserted column will be populated with GETDATE() to have when the data are inserted. And instance column have the newid() value. one user request will have one unique id; may have million rows. The below are the queries which will be executed concurrently, which causing the deadlock. Please advise meQuery1: "Set transaction isolation readuncommitted Delete P from Products (Nolock) where instance = 'XXXX-xxx-xxx-xx'"Query2: "Set transaction isolation readuncommitted Delete P from Products (Nolock) where inserted&amp;lt;=DATEADD(hh, -10, getdate())"Note: The nonclustered index is created on instance column.PLEASE ADVISE me which lock I can use in this scenario.Note I couldnt able to primary key as it is consuming time when I insert 10 million rows to the table (this for one transaction; there are 20 concurrent transations). The report should be generated sooner. And my procedure has multiple 35 DML statments, there are around 15 DELETE statements for instance column with other columns( DElete from table where instance = @instance and col1 = @col1)</description><pubDate>Mon, 25 Feb 2013 11:17:57 GMT</pubDate><dc:creator>VASUforSQL</dc:creator></item></channel></rss>