Performance improvement on SQL query joining table on itself I'm running this query on a table with approximately 20MM records in it.  It's a very slow query, and I'm wondering if there's a better way to accomplish this that might run faster ?

delete previous
output Deleted.*
into table_A
from table_B as previous
inner join table_B as latest on previous.field_1 = latest.field_1
    and previous.field_2 = latest.field_2
    and previous.field_3 = latest.field_3
where previous.[feed_id] &lt; latest.[feed_id]
    and previous.[condition_1] in (
        '1'
        ,'2'
        )
    and latest.[condition_1] = '3'
    and latest.[feed_id] = 500
You are doing the entire delete in one transaction that will possibly bloat your transaction log and it will crawl like a sloth.

There is a much better way of doing a delete - break it into chunks or you can do deletes using Careful Batching.

Also, its always a good habit to refer objects with their schema.