MySQL Forums
Forum List  »  Newbie

Re: MYsql getting crash
Posted by: Rick James
Date: November 06, 2009 10:28AM

Yes, but it is trickier because there could be dups. I assume it is an INDEX. If not, then it the following code will be very slow.
SELECT @tsa := DATE_SUB(MIN(ts), INTERVAL 1 SECOND) FROM tbl;
Loop:
    SELECT @tsz := ts FROM tbl LIMIT 100, 1;  # reach for convenient stopper
    # this will delete up to 100 rows (or more, if dup values for ts):
    DELETE FROM tbl WHERE ts >  @tsa 
                      AND ts <= @tsz
                      AND ts < $cutoff
                      AND ...;
    SELECT @tsa := @tsz;
    $finished = SELECT @tsz > $cutoff FROM tbl;
    if $finished, exit loop
    (optional) sleep 1 second;
EndLoop.
(@tsa, @tsz could be done with PHP/Perl/etc variables or Stored Procedure locals instead of MySQL variables.)

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
October 30, 2009 10:16AM
November 06, 2009 02:33AM
Re: MYsql getting crash
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.