Skip to content

Instantly share code, notes, and snippets.

@sobstel
Created May 8, 2011 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobstel/961414 to your computer and use it in GitHub Desktop.
Save sobstel/961414 to your computer and use it in GitHub Desktop.
MySQL fast data load
#1
LOAD DATA INFILE...
#2
ALTER TABLE name DISABLE KEYS; // tells MySQL to stop updating nonunique indexes
INSERT ...
...
ALTER TABLE name ENABLE KEYS; // re-creates missing indexes (much faster than inserting one by one)
#3 (InnoDB)
BEGIN;
INSERT ...
...
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment