MySQL Forums
Forum List  »  MyISAM

Re: how to avoid lock table, wait online
Posted by: Jay Pipes
Date: September 05, 2005 01:20PM

A simple solution would be to not issue the DELETE every time a record is processed, but rather do the DELETE statement only very occasionally (say every 24 hours), running something like:

LOCK TABLES my_table WRITE;
DELETE FROM my_table WHERE insert_time < DATE_SUB(NOW(), INTERVAL 1 DAY);
UNLOCK TABLES;

There's really no benefit you get from DELETEing records from a table at all, unless you really need to reduce storage requirements. Leaving the records in the table for 24 hours would be just fine.

Another tip is to make sure you have only the indexes on the table which you absolutely need. Tables having lots of UPDATE/DELETE statements should have as few indexes on them as possible.

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
4769
September 05, 2005 03:41AM
Re: how to avoid lock table, wait online
2443
September 05, 2005 01:20PM
2143
September 06, 2005 02:57AM


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.