tags:

views:

35

answers:

2

There is a database table for logging purpose only so old records are useless. Is there an easy way to automatically delete old records and keep most recent records only (say, records created in last 7 days, or, the latest 1 million records). The table uses MyISAM engine and have a timestamp column but do not have primary key (for fast insertion).

+1  A: 

Set up a cron job to run a query to do so.

Ignacio Vazquez-Abrams
A: 

U can put your Logic in Insert Trigger to delete your old records

Nitesh Katare
@Nitesh - But that would slow down certain insertions, right?
powerboy
you can put some condition in the procudure ex: if Total Number of Records in more than 1 million den the trigger has to fire in this way u can maintain the same performance.
Nitesh Katare