February 19, 2007

Quicker Ways to Import Data into InnoDb

For those of you who ever have to put data into MySQL database, here’s a quick little tip. If you’re importing into a table that is using the InnoDb engine (versus the MyISAM), wrap your import file in the following:

SET AUTOCOMMIT=0;
SET UNIQUE_CHECKS=0;
… SQL import statements …
SET UNIQUE_CHECKS=1;
COMMIT;

 This will significantly improve the import time (by orders of magnitude, for imports beyond tens of thousands of records).

Edit: Quick point of reference. Importing 60,000 records (simple inserts) took about 10 minutes or about 10,000 per minute. After switching this fix in, I inserted 10,000 more records in under 10 seconds (so fast, I forgot to time it).

Filed under: MySQL — Michi @ 10:26 pm

Share this

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Reddit
  • StumbleUpon
  • del.icio.us
  • description
  • Technorati
  • Slashdot
  • co.mments
  • NewsVine

Related

I've always wondered what all of the folder names meant on Linux, and Saturday's post on Slashdot about the /etc folder answered it. From the responses: All the system directories were kept to three letters, and all of the...
Some companies thrive on the idea of having others utilize their service in new, creative ways. Facebook has an API. eBay has an API. Google has 20 APIs. People mash Google Maps and Craigslist. Yahoo just released a product which...

No Comments »

TrackBack URI | Blog RSS | Comment RSS

No comments yet.

What do you think?