none
SqlBulkCopy slow?

    Question

  • I am using the following code bulk copy data to SQL server. The batch size normally is small. Most of them, this code is running very fast. However, I can see it can be slow up to 6 second just commit one record!

    The dest table has around 100 columns but only has less 10 rows in testing. that is meaning, I don't think rebuild indexing be an issue.

    Does anyone see similar behavior?

    environment:

    Testing Client : .NET 4.0 sharing with same machine hosting SQL server. 

    SQL: SQL Server 2012 Dev edition 

    using (var bcp = new SqlBulkCopy(connectionString))
    {
    	bcp.DestinationTableName = "MyTable";
    	foreach(DataColumn column in InMemoryTable.Columns)
    		bcp.ColumnMappings.Add(column.ColumnName, column.ColumnName);
    	Console.WriteLine("{0} Begin Commit {1} data", DateTime.Now.ToString("HH:mm:ss.fff"), InMemoryTable.Rows.Count);
    	bcp.WriteToServer(InMemoryTable);
    	Console.WriteLine("{0} End Commit {1} data", DateTime.Now.ToString("HH:mm:ss.fff"), InMemoryTable.Rows.Count);
    }



    • Edited by TravelMan Friday, November 01, 2013 3:06 AM
    Friday, November 01, 2013 3:04 AM

Answers