MySQL Forums
Forum List  »  Newbie

Re: MYsql getting crash
Posted by: Rick James
Date: October 30, 2009 10:16AM

Don't delete all at once. Delete in smallish chunks -- perhaps 100 to 1000 rows. If you have an AUTO_INCREMENT id on the table, the write a loop something like this:
$a = 0;
$maxid = SELECT MAX(id) FROM tbl;
WHILE ($a < $maxid)
    DELETE FROM tbl WHERE id BETWEEN a AND a + 99 AND ...;
    $a = $a + 100;
    (optional) sleep 1 second;

If you don't have an auto_increment id, there are other tricks to play.

That will take awhile to run, but it won't lock the table for long enough to notice.

Options: ReplyQuote


Subject
Written By
Posted
October 08, 2009 03:05AM
October 10, 2009 10:55PM
October 26, 2009 11:51PM
October 21, 2009 10:57PM
October 21, 2009 11:13PM
October 22, 2009 12:23AM
October 22, 2009 09:21AM
October 26, 2009 11:56PM
October 27, 2009 07:37AM
October 28, 2009 03:16AM
October 28, 2009 10:23PM
October 29, 2009 12:24AM
October 29, 2009 08:20PM
October 29, 2009 11:39PM
Re: MYsql getting crash
October 30, 2009 10:16AM
November 06, 2009 02:33AM
November 06, 2009 10:28AM
October 27, 2009 03:14AM
October 27, 2009 03:16AM
December 06, 2009 07:51AM
December 30, 2009 11:42PM
December 31, 2009 03:06AM


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.