As I was working on improving the uploading process of my place's web page, I saw the way they handled uploading a large dataset:
SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;
[do import here]
COMMIT;
SET autocommit=1;
SET unique_checks=1;
SET foreign_key_checks=1;
This is for mainly two reasons:
- Avoiding unnecessary constraint checks during the import.
- Allowing bulk inserts in a single transaction. But this also means that you have to make sure the data is clean and doesn't have duplicate rows. Because MySQL won't check it for you.