C# - Inserting multiple rows using a stored procedure

后端 未结 5 1636
青春惊慌失措
青春惊慌失措 2021-02-15 14:17

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:38

    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

提交回复
热议问题