SQL Server query performance when there's a dynamic condition in where clause -
let's have query a:
select count(1) mytable date_created < dateadd(dd, 3, getdate())
and query b:
select count(1) mytable date_created < '2013-05-24'
when queries run, how compiler optimize query a? re-evaluate dateadd , getdate each row in mytable?
the reason asking because ran several tests see queries faster , result seems indicate there's no huge difference in performance of two, kinda counter-intuitive. thanks.
getdate
runtime constant , won't repeatedly re-evaluated.
chances whole expression dateadd
evaluated once.
Comments
Post a Comment