Which Where condition in Datetime will be faster?

I have a Datetime column named CreatedOn in a table. CreatedOn is also part of the non-clustered index where the order is decreasing.

Earlier in the where clause I had a condition like this

WHERE DateDiff(d,CreatedOn,GetDate()) < 180 AND ... other conditions

      

I changed this to

WHERE CreatedOn > '2012-04-04 00:00:00.000' AND ... other conditions

      

where i am calculating the clipping date in c # code and then putting that in adhoc request.

In my opinion the second condition should be faster, but I don't see a significant change in query execution time yet. But as the table grows in size, which one will run faster?

+3


source to share


1 answer


Second form.



Including functions on columns invalidates the use of indexes (in almost all cases, so just follow this rule at all times). See "Ten Common SQL Programming Mistakes" , number 2

+6


source







All Articles