List:General Discussion« Previous MessageNext Message »
From:Baron Schwartz Date:August 14 2007 8:53pm
Subject:Re: Scheduled events
View as plain text  
Hi,

Beauford wrote:
> Hi,
> 
> I have been trying for days to find a simple command in MySQL where I can
> automatically delete records based on some criteria after a certain
> timeframe.
> 
> I found this in the MySQL manual, but I guess it only works with version
> 5.1+. Unfortunately the version I need this to work on is 4.1, and can't be
> upgraded.
> 
> CREATE EVENT e_hourly
>     ON SCHEDULE 
>       EVERY 1 HOUR
>     COMMENT 'Clears out sessions table each hour.'
>     DO
>       DELETE FROM something;
> 
> Is there something similar in version 4.1 that will do the same thing.

No.  But there are cron jobs :-)  And if you're deleting many rows and 
you don't want to interfere with other running queries (sounds like this 
is an OLTP system), try MySQL Archiver with the --purge argument 
(http://mysqltoolkit.sourceforge.net/).  It's much more efficient at 
large data volumes than a single DELETE statement.

Baron
Thread
Scheduled eventsBeauford14 Aug
  • Re: Scheduled eventsBaron Schwartz14 Aug
    • RE: Scheduled eventsBeauford14 Aug
      • Re: Scheduled eventsDan Buettner14 Aug
      • Re: Scheduled eventsBaron Schwartz15 Aug
      • Re: Scheduled eventsWarren Young15 Aug