MySQL Forums
Forum List  »  InnoDB

Re: Most efficient update
Posted by: Jay Pipes
Date: July 06, 2005 12:36PM

If you run the INSERT statements with a LOCK TABLES table_name WRITE before doing the inserts, then, no, it won't because the DROP INDEX will have to wait for the inserts to complete. Otherwise, in the default AUTOCOMMIT mode set to 1, the DROP INDEX would execute "in between" inserts, and possibly cause locking.

Note: If you took my advice above on using INSERT DELAYED, *don't* use LOCK TABLES, as INSERT DELAYED uses a separate thread.

This kind of situation is a bit tricky and will require you to find a good balance of if, when and how often to recreate indexes or use ANALYZE TABLE. It will require you to benchmark a couple scenarios and see what works best for your situation... You may want to leave the index in there and try the batch inserts normally; if performance suffers, try dropping the index before and re-creating the index after the inserts. Use LOCK TABLES table_name WRITE; before either to ensure that you lock the table for as little time as possible and give priority to write operations. Also ensure that SET AUTOCOMMIT=0; at the start of your session.

I'd highly recommend running some benchmarks on a test system to determine what's best in this scenario. It might work out that you do an ANALYZE TABLE at a regularly scheduled interval (during off-peak hours) and leave the index intact during inserts...

Hope this is what you were looking for,

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
3646
July 04, 2005 08:43PM
2179
July 04, 2005 11:59PM
2283
July 05, 2005 10:45AM
2026
July 05, 2005 11:13AM
2013
July 05, 2005 11:57AM
2178
July 05, 2005 12:54PM
2101
July 06, 2005 11:18AM
Re: Most efficient update
2090
July 06, 2005 12:36PM
2035
July 07, 2005 11:14AM
2108
July 07, 2005 11:26AM
2005
July 07, 2005 03:11PM
2355
July 29, 2005 06:56AM


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.