I received a claim for an incredible slow query in our print label software. With SQL Profiler I got the offender query and started to test in SSMS with really bad performance (around 00:50:00). The query is long, and the tables are big, but there is a
WHERE
...
fieldX > {ts '2016-01-01 00:00:00} /* fieldX is a DATETIME */
...
I changed to
WHERE
...
fieldX > DATEADD(YYYY, -1, GETDATE())
...
And the execution time now shows 00:00:00 !!
I just want understand why?