C# - Inserting multiple rows using a stored procedure

后端 未结 5 1503
清酒与你
清酒与你 2021-02-15 14:05

I have a list of objects, this list contains about 4 million objects. there is a stored proc that takes objects attributes as params , make some lookups and insert them into tab

5条回答
  •  不思量自难忘°
    2021-02-15 14:18

    1. Like Abe metioned: drop indexes (and recreate later)
    2. If you trust your data: generate a sql statement for each call to the stored proc, combine some, and then execute.
      This saves you communication overhead.
    3. The combined calls (to the stored proc) could be wrapped in a BEGIN TRANSACTION so you have only one commit per x inserts

    If this is a onetime operation: do no optimize and run it during the night / weekend

提交回复
热议问题