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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -