WHERE (h.timestamp BETWEEN GETDATE() - 14 AND GETDATE())
The planner does a table scan with that "Where".
There's nothing in that predicate which will force a scan. Assigning the results of the date manipulation to a variable first will just remove the ability of the optimiser to sniff the values, will probably make the row estimation less accurate.
Gail Shaw Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci) SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply