Ok, I’ve got about 175k INSERT statements, pretty big INSERT statements, example:
INSERT INTO `gast` (`ID`,`Identiteitskaartnummer`,`Naam`,`Voornaam`,`Adres`,`Postcode`,`Stad`,`Land`,`Tel`,`Gsm`,`Fax`,`Email`,`Creditcardnummer`) VALUES ('100001','5121-1131-6328-9416','Cameron','Rhoda','Ap #192-1541 Velit Rd.','54398','Catskill','Bermuda','1-321-643-8255','(120) 502-0360','1 48 428 3971-3704','tempor@justo.org','8378-3645-3748-8446');
(Disregard the fact this is in Dutch). All the data is completely random.
I’ve got to do this about 3 to 4 times. Querying 100k INSERT statements takes about an hour on my PC. Is there any way to do this faster without altering the INSERT statements? I’m using MySQL Workbench. Thanks.
EDIT
I’ve tried everything suggested so far. Using only one INSERT but multiple VALUES gives me an error that the INSERT statement is too big. Disabling the indexes before inserting doesn’t improve performance either.
I’ve also tried loading an sql file through command line, but that doesn’t do anything either…
Insert performance varies from 0.015s to 0.032s per INSERT.
INSERT all of the data into one table – the table you’re going to reseed your database with – and then issue an INSERT SELECT statement because it will then execute it as a batch instead of 175K different statements.
Also, when you reseed your database with the INSERT SELECT statement, turn off contraints on the target table
ALTER TABLE yourtablename DISABLE KEYSand then turn them back on afterwardsALTER TABLE yourtablename ENABLE KEYS.I would also personally build a covering index on the seed data table because then it wouldn’t have to read a data page.