This post originated from an RSS feed registered with Python Buzz
by Phillip Pearson.
Original Post: SET AUTOCOMMIT=0
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
If you are going to do a lot of INSERT queries into an InnoDB table, you can save a lot of time by wrapping them all up into a single transaction. MySQL flushes various things to disk at the end of a transaction, so you save a lot of time waiting for disks to flush their caches if you have a million little transactions rather than one huge one.
Before you do your big job, send this query:
SET AUTOCOMMIT=0
and at the end:
COMMIT
(you might want to SET AUTOCOMMIT=1 if you want to go back to normal behaviour for the rest of the script / db connection).