Delete large amount of data in sql server

后端 未结 7 1378
误落风尘
误落风尘 2021-02-15 15:30

Suppose that I have a table with 10000000 record. What is difference between this two solution?

  1. delete data like :

    DELETE FROM MyTable
             
    
    
            
7条回答
  •  暖寄归人
    2021-02-15 16:07

    Option 1 will create a very large transaction and have a big impact on the log / performance, as well as escalating locks so that the table will be unavailable. Option 2 will be slower, although it will generate less impact on the log (assuming bulk / full mode)

    If you want to get rid of all the data, Truncate Table MyTable would be faster than both, although it has no facility to filter rows, it does a meta data change at the back and basically drops the IAM on the floor for the table in question.

提交回复
热议问题