What's the fastest way to bulk insert a lot of data in SQL Server (C# client)

前端 未结 8 1213
予麋鹿
予麋鹿 2020-11-28 22:39

I am hitting some performance bottlenecks with my C# client inserting bulk data into a SQL Server 2005 database and I\'m looking for ways in which to speed up the process.

8条回答
  •  忘掉有多难
    2020-11-28 23:19

    You're already using SqlBulkCopy, which is a good start.

    However, just using the SqlBulkCopy class does not necessarily mean that SQL will perform a bulk copy. In particular, there are a few requirements that must be met for SQL Server to perform an efficient bulk insert.

    Further reading:

    • Prerequisites for Minimal Logging in Bulk Import
    • Optimizing Bulk Import Performance

    Out of curiosity, why is your index set up like that? It seems like ContainerId/BinId/Sequence is much better suited to be a nonclustered index. Is there a particular reason you wanted this index to be clustered?

提交回复
热议问题