Skip navigation links

MySQL Forums :: Newbie :: Delete taking a long time to complete


Advanced Search

Re: Delete taking a long time to complete
Posted by: Greg Hines ()
Date: April 29, 2010 03:49PM

VIKAS . Wrote:
-------------------------------------------------------
> Hi,
>
> You can limit the number of rows to delete as
>
> DELETE FROM Table1 WHERE StrID=iSid AND DOB >=
> StartDate limit 1000;
>
>
> This might help you out.

Tried that with a SP like:-
BEGIN
	DECLARE cnt INT;
	SET cnt=10000;
	WHILE cnt = 10000 DO
		SET @s = CONCAT('DELETE FROM Table1 WHERE StrID = ',  SID, ' AND DOB >= ', dDOB, ' LIMIT 10000');
		PREPARE stmt FROM @s;
		EXECUTE stmt;
		SET cnt = ROW_COUNT();
		DEALLOCATE PREPARE stmt;
	END WHILE;
END


Used various limit values and it always took longer than using one delete statement. Suggestions??

Greg

Options: ReplyQuote


Subject Written By Posted
Delete taking a long time to complete Greg Hines 04/29/2010 12:23AM
Re: Delete taking a long time to complete VIKAS . 04/29/2010 02:13PM
Re: Delete taking a long time to complete Greg Hines 04/29/2010 03:49PM
Re: Delete taking a long time to complete Rick James 04/29/2010 09:38PM
Re: Delete taking a long time to complete Greg Hines 04/29/2010 10:13PM
Re: Delete taking a long time to complete Rick James 04/29/2010 11:26PM
Re: Delete taking a long time to complete Greg Hines 04/29/2010 11:45PM
Re: Delete taking a long time to complete Rick James 04/30/2010 07:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.