SQL Server insert performance

后端 未结 8 1213
终归单人心
终归单人心 2020-12-29 06:01

I have an insert query that gets generated like this

INSERT INTO InvoiceDetail (LegacyId,InvoiceId,DetailTypeId,Fee,FeeTax,Investigatorid,SalespersonId,Creat         


        
8条回答
  •  春和景丽
    2020-12-29 06:29

    Some suggestions for increasing insert performance:

    • Increase ADO.NET BatchSize
    • Choose the target table's clustered index wisely, so that inserts won't lead to clustered index node splits (e.g. autoinc column)
    • Insert into a temporary heap table first, then issue one big "insert-by-select" statement to push all that staging table data into the actual target table
    • Apply SqlBulkCopy
    • Place a table lock before inserting (if your business scenario allows for it)

    Taken from Tips For Lightning-Fast Insert Performance On SqlServer

提交回复
热议问题