My process is doing a insert into to a backup table 'B from a table 'A' which gets updated daily[truncate and load] in the azure sql db. A column 'TSP' [eg value =2022-12-19T22:06:01.950994] is present in both tables. TSP for all rows inserted in a day is same. Later in the day, I'm supposed to delete older data. Currently using 'delete from 'B' where TSP<'today-1day' logic Is there a way to optimize this delete using index or something?
SSMS suggested to create non clustered index on the table.TSP column. I tested it but seems there isn't much difference. If this was the data: 50mil TSP1 50mil TSP2 50mil TSP3 My expectation was it would skip scanning TSP2,TSP3 rows and delete TSP1. Whereas if table doesn't have index it would need to scan all 150mil rows.