I have the following statement: SELECT f.PAR_GUID, MAX(DATEDIFF(DAY, f.EVT_DT + f.EXP_RSP_DYS, CURRENT_DATE)) FROM JET_LTR f WHERE (f.EXP_RSP_DYS > -1) AND (f.RSP_RCVD_DT IS NULL) AND (DATEDIFF(DAY, f.EVT_DT + f.EXP_RSP_DYS, CURRENT_DATE) > f.EXP_RSP_DYS) GROUP BY 1
The DB is inactive all night. Each morning, when I run this for the first time that day, it will take 40 seconds to complete. However, without any changes to the DB, if I run it subsequent times the same day, the subsequent times it will complete in less than half a second. What can I do, to make this statement run in sub-second time, always, including the first time it's run? Also, would using a computed field help the speed at all (for the MAX() function). Thanks in advance.
