locking - SQL Server Delete Lock issue -
i have sql server database deleting rows 3 tables a,b,c
in batches conditions through sql script scheduled in sql job. job runs 2 hours tables have large amount of data. while job running, front end application not accessible (giving timeout error) since application inserts , updates data in these same tables a,b,c
.
is possible front end application run in parallel without issues while sql script running? have checked locks on table , sql server acquiring page locks. can read committed snapshot
or snapshot
isolation levels or converting page locks row locks here. need advice.
split operation in 2 phases. in first phase, collect primary keys of rows delete:
create table #templist (id int); insert #templist select id yourtable
in second phase, use loop delete rows in small batches:
while 1=1 begin delete top (1000) yourtable id in (select id #templist) if @@rowcount = 0 break end
the smaller batches allow front end applications continue in between them.
Comments
Post a Comment