dbTalk Databases Forums  

deadlock help please

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss deadlock help please in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wolfing
 
Posts: n/a

Default deadlock help please - 06-15-2007 , 10:43 AM






I have a table that every 30 minutes needs to be repopulated from
another table that is recreated from scratch just before.
What I did was this:
CREATE PROCEDURE BatchUpdProducts AS
begin transaction
delete products
insert into products
select * from productsTemp
commit transaction
GO

This takes about 30 seconds to run. I tried it doing it with a cursor,
row by row, but it took like 30 minutes to run instead. The problem
is with the fast approach is, once in a while I get a deadlock error
in different areas trying to access the products table. Using SQL
Server 2000 by the way.
Any ideas?


Reply With Quote
  #2  
Old   
Seribus Dragon
 
Posts: n/a

Default Re: deadlock help please - 06-15-2007 , 11:17 AM






Are those section that are getting the dead lock just doing read only or
do the need to right?

Wolfing wrote:
Quote:
I have a table that every 30 minutes needs to be repopulated from
another table that is recreated from scratch just before.
What I did was this:
CREATE PROCEDURE BatchUpdProducts AS
begin transaction
delete products
insert into products
select * from productsTemp
commit transaction
GO

This takes about 30 seconds to run. I tried it doing it with a cursor,
row by row, but it took like 30 minutes to run instead. The problem
is with the fast approach is, once in a while I get a deadlock error
in different areas trying to access the products table. Using SQL
Server 2000 by the way.
Any ideas?


Reply With Quote
  #3  
Old   
Wolfing
 
Posts: n/a

Default Re: deadlock help please - 06-15-2007 , 11:51 AM



On Jun 15, 12:17 pm, Seribus Dragon <Seribus.n... (AT) seribus (DOT) com> wrote:
Quote:
Are those section that are getting the dead lock just doing read only or
do the need to right?

Wolfing wrote:
I have a table that every 30 minutes needs to be repopulated from
another table that is recreated from scratch just before.
What I did was this:
CREATE PROCEDURE BatchUpdProducts AS
begin transaction
delete products
insert into products
select * from productsTemp
commit transaction
GO

This takes about 30 seconds to run. I tried it doing it with a cursor,
row by row, but it took like 30 minutes to run instead. The problem
is with the fast approach is, once in a while I get a deadlock error
in different areas trying to access the products table. Using SQL
Server 2000 by the way.
Any ideas?
Only read, the only process that writes is the one I showed above that
runs every 30 minutes



Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: deadlock help please - 06-15-2007 , 11:56 AM



Wolfing (wolfing1 (AT) gmail (DOT) com) writes:
Quote:
I have a table that every 30 minutes needs to be repopulated from
another table that is recreated from scratch just before.
What I did was this:
CREATE PROCEDURE BatchUpdProducts AS
begin transaction
delete products
insert into products
select * from productsTemp
commit transaction
GO

This takes about 30 seconds to run. I tried it doing it with a cursor,
row by row, but it took like 30 minutes to run instead. The problem
is with the fast approach is, once in a while I get a deadlock error
in different areas trying to access the products table. Using SQL
Server 2000 by the way.
If it is OK for you that the batch process is the deadlock victim, you
can add "SET DEADLOCK_PRIORITY LOW" first in the procedure.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.