SqlBulkCopy performance

前端 未结 1 1412
Happy的楠姐
Happy的楠姐 2021-02-09 00:45

I am working to increase the performance of bulk loads; 100\'s of millions of records + daily.

I moved this over to use the IDatareader interface in lieu

1条回答
  •  长发绾君心
    2021-02-09 01:30

    Why not use SSIS directly?

    Anyway, if you did a treaming from parsing to IDataReader you're already on the right path. To optimize SqlBulkCopy itself you need to turn your focus to SQL Server. The key is minimally logged operations. You must read these MSDN articles:

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

    If your target is a B-Tree (ie a clustered indexed table) unfortunately one of the most important tenets of performant bulk insert, namely the sorted-input rowset, cannot be declared. Sis simple as this, ADO.Net SqlClient does not have the equivalent of SSPROP_FASTLOADOPTIONS -> ORDER(Column) (OleDb). Since the engine does not know that the data is already sorted it will add a Sort operator in the plan which is not that bad except when it spills. To avoid spills, use a small batch size (~10k). See my original point: all these are just options and clicks to set in SSIS rather than digging through OleDB MSDN spec...

    If your data stream is unsorted to start with or the destination is a heap then my point above is mute.

    However, achieving minimally logging is still a must for decent performance.

    0 讨论(0)
提交回复
热议问题