sql - Delete more than 6 million rows so SLOW -
i have sp needs delete more 6 million rows.
i tried approach still execution time slow.
declare @continue bit = 1 -- delete ids not between starting , ending ids while @continue = 1 begin set @continue = 0 delete top (10000) u table1 u (readpast) id = @id , nid in (select nid #node group nid) if @@rowcount > 0 set @continue = 1 end
any other suggestions?
your loop logic looks ok
as other have said @ application design
can use staging tables , able truncate
if table has fk , confident not going violate them disable fk , re-enable
if have delete trigger , need delete 6 million every day need reevaluate design
look @ optimizing select put in delete
select top (10000) u table1 u (readpast) join #node on u.nit = #node.nit , u.id = @id
Comments
Post a Comment