Each week a cronjob fires that deletes about 500,000 records from a MySQL table which uses the InnoDB engine. The table contains web log data for weekly processing and afterwards data which is no longer needed is deleted. There are 3 indexes on this table (no foreign keys), including time which is a unix timestamp.
DELETE FROM global_viewlog WHERE time<1354391592
The problem is that this query when ran last week took over 2 hours to run and during that time my entire server was lagging. 'iotop' revealed the hard disks where being written to by MySQL quote vastly and the server load dramatically increased to unhealthy levels.
The table gets written to every click. Is there an elephant in the room that I'm not seeing? I.e., something blindly obvious to optimize this weekly query?
Thanks