SQL Server DELETE is slower with indexes

后端 未结 5 1667
忘掉有多难
忘掉有多难 2021-01-02 20:21

I have an SQL Server 2005 database, and I tried putting indexes on the appropriate fields in order to speed up the DELETE of records from a table with millions

5条回答
  •  星月不相逢
    2021-01-02 21:11

    JohnB is deleting about 75% of the data. I think the following would have been a possible solution and probably one of the faster ones. Instead of deleting the data, create a new table and insert the data that you need to keep. Create the indexes on that new table after inserting the data. Now drop the old table and rename the new one to the same name as the old one.

    The above of course assumes that sufficient disk space is available to temporarily store the duplicated data.

提交回复
热议问题