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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -