Is SQL DATEDIFF(year, …, …) an Expensive Computation?

前端 未结 3 1771
渐次进展
渐次进展 2021-01-19 16:08

I\'m trying to optimize up some horrendously complicated SQL queries because it takes too long to finish.

In my queries, I have dynamically created SQL statements wi

3条回答
  •  孤城傲影
    2021-01-19 16:33

    DATEDIFF is quite efficient compared to other methods of handling of datetime values, like strings. (see this SO answer).

    In this case, it sounds like you going over and over the same data, which is likely more expensive than using a temp table. For example, statistics will be generated.

提交回复
热议问题