Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the quickest way to import 60m records into SQL

I have a 5-6 tables in my database that I need to populate with test data to test peroformance in my app.

I can write a code and do a bulk insert my prediction is that it will take nearly 3 days to run so I assumed there must be a quicker way.

Any ideas?

like image 903
Jon Avatar asked May 25 '10 09:05

Jon


2 Answers

Depending on how you are generating your data, SSIS may be the best way to insert data.

Also, make sure you turn off all triggers where possible and remove as many indexes as possible, re-adding them afterwards.

like image 181
cjk Avatar answered Oct 16 '22 08:10

cjk


SSIS is one way to go, but you'll either be using the Bulk Insert Task, or looping through the file and calling an INSERT INTO statement. There is BCP available.

like image 24
Neil Knight Avatar answered Oct 16 '22 09:10

Neil Knight