SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UPDATE , DELETE result is blocking
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jampandu
Starting Member

India
8 Posts

Posted - 03/18/2014 :  00:31:11  Show Profile  Reply with Quote
Hi Experts,

I have a situation where deleting old records is blocking updating latest records on highly transactional table and getting timeout errors from application.

In details,
I have one table called Tran_table1 in OLTP database. This Tran_table1 is highly transactional table, it will receive data for insert/update continuously

While archiving 2 years old records from Tran_table1 into Tran_table1_archive in batches(using DELETE OUTPUT INTO clause)
,if there is any UPDATEs on Tran_table1,these updates are getting blocked and result is timeout errors in application.

Is there any SQL Server hints to avoid blocking ..
Please suggest if there is any other alternative way.


Thanks!

James K
Flowing Fount of Yak Knowledge

3575 Posts

Posted - 03/18/2014 :  05:04:07  Show Profile  Reply with Quote
What is your batch size? May be you need to reduce it further. How are you separating batches? Using a looping construct (WHILE etc.) or GO# ? Perhaps you also need to insert a WAIT FOR delay between batches.
Go to Top of Page

Jampandu
Starting Member

India
8 Posts

Posted - 03/18/2014 :  23:30:42  Show Profile  Reply with Quote
I tried with batch size of 100 /1000/10000 in WHILE LOOP,but no luck.
let me try with WAIT FOR delay and update you

Thanks!

Edited by - Jampandu on 03/18/2014 23:33:08
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3575 Posts

Posted - 03/19/2014 :  15:28:27  Show Profile  Reply with Quote
Are you able to delete even one batch, without using any looping? Also, check if the OUTPUT INTO clause is causing any issues - perhaps the target table is blocking. You can run sp_who2 and see what is blocking what. Also, I prefer GO # rather than while loops for this sort of thing:
DELETE TOP (10) FROM YourTable;
GO 50
That will delete 50x10 = 500 rows from your table.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000