MySQL Forums
Forum List  »  Newbie

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
Re: Delete taking a long time to complete
April 29, 2010 03:49PM


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.