If I stop a long running query, does it rollback?

后端 未结 12 1912
忘了有多久
忘了有多久 2020-12-06 04:23

A query that is used to loop through 17 millions records to remove duplicates has been running now for about 16 hours and I wanted to know if the query is sto

12条回答
  •  死守一世寂寞
    2020-12-06 05:05

    DELETES that have been performed up to this point will not be rolled back.


    As the original author of the code in question, and having issued the caveat that performance will be dependant on indexes, I would propose the following items to speed this up.

    RecordId better be PRIMARY KEY. I don't mean IDENTITY, I mean PRIMARY KEY. Confirm this using sp_help

    Some index should be used in evaluating this query. Figure out which of these four columns has the least repeats and index that...

    SELECT *
    FROM MyTable
    WHERE @long = longitude
      AND @lat = latitude
      AND @businessname = BusinessName
      AND @phoneNumber = Phone
    

    Before and After adding this index, check the query plan to see if index scanning has been added.

提交回复
热议问题