I just want to check my logic.
Let's say I want to find all the new products in the last 30 days My current process is:
Choose the product name from the manufacturer DATEDIFF (d, CreateDate, GETDATE ()) & lt; 30
However, I understand that a function like DATEDIFF will not use the non-clustered index created on CreateDate
. Therefore, my query is of the following process Will run quickly using:
select product from product name WHERE CreateDate & gt; = DATEADD (d, -30, GETDATE ()) and CreateDate & lt; BTW, I do not have a SQL server, from where I am so much that I can not test using the execution plan.
Yes, you are right, the second question will be fast because it is available which is available on CreateDate Can use index
No comments:
Post a Comment