Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's how my colleague described it to me, seems he misspoke or I misremembered.

I checked the documentation and it says now() is evaluated at most once per request.

The point was now() and friends prevents optimization on the server we use, because they're not treated as constants.



It depends on context, for example this is true for SQL server if you have a filtered index based on datetime.

If you use a constant or set a @variable ahead of time, it will use the filtered index, but if you just use =now() equivalent

(or in SQL server GETDATE()) it will not. (You may also need to use OPTION(Recompile))




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: