I am comparing two queries. One query uses
WHERE CAST(datetime_column AS DATE) = CAST('2019-06-24 00:00:00.000' AS DATE),
and the other does
WHERE datetime_column >= '2019-06-24' AND datetime_column < '2019-06-25';
The first one does an index scan and runs slowly (estimate number of rows to be read = 560 million), the second one returns instantly and does an index seek (estimate number of rows to be read = 848).
Since they are both running on the same range, and the slower one does not use a function on the column, how come it is slower?
I have tried to run the slower query with a smaller range and it did run faster, but I can't rely on a smaller range.