Hi all I am getting an alert with my idera tool showing that there is a table scan occurring with the script below and that I should revise it. However, I am foggy on how to pull the column out of the predicate so that that the query does exactly the same but with a different logic flow.Will you show me how to revise this?
CREATE PROCEDURE [dbo].[deleteExpiredJobs] AS DELETE FROM RunningJobs WHERE DATEADD(s, Timeout, StartDate) < GETDATE()
Thanks for your code. I tried it but I am still getting a table scan even with an index on the strtdate column.
My best bet here would be that your query seems to be covering more than 20% of the total rows in the table. If that's the case then the optimizer will go for a scan even if an index is defined on the column.