I'm working on a project that involves importing roughly 7 million rows of data from a denormalised MySQL database into a fully-normalised MSSQL database system.
I've written software that transforms the data from the format used in the MySQL DB (imported through large CSV files) and then inserts it into MSSQL, however in my LAN environment against my development server (over gigabit links, with a reasonably specc'd out server) I can never seen to get more than 150 INSERT operations per second.
I'm just doing:
using(SqlConnection con = GetConnection()) {
SqlCommand cmd = con.CreateCommand();
// add parameters to cmd.Parameters here
foreach(Record r in recordsToInsert) {
cmd.Parameters["@foo"] = r.Foo;
cmd.ExecuteNonQuery();
}
}
So I'm re-using both the connection and command objects, what gives?
I'm going to be using BULK INSERT for the production data, which should hopefully be faster, but does anyone have any suggestions?
Add your 2¢