I have the query of the following form:
DECLARE @date DATETIME = <some_date>
SELECT ....
FROM a
WHERE <some_conditions> AND a.LastEvent < @date
LastEvent column is of type DATE
.
Query works pretty fast. But if I change @date type to DATE
query execution seems not going to ever finish. If I comment out the condition
AND a.LastEvent < @date
query works fast again.
I'm surprised how slight type change of the parameter can affect the performance but I have no idea why this happens.