Hi everyone,
I recently read up on making query sargeable to improve performance. Up until now I really never considered this.
I have the following query, nothing complex but it will be run against many rows.
Now if I understood sargeable and I was to use an index on dCreated for that query it would totally ignore the index. But I'm not sure how to improve it, I just need to get todays record from a datetime ignoring the 'time' part on both side.
I recently read up on making query sargeable to improve performance. Up until now I really never considered this.
I have the following query, nothing complex but it will be run against many rows.
Code:
SELECT iRecordNumber, iRecordTypeID, COUNT(iRecordID) AS nbRecord
FROM tblRecord
WHERE (fkCreatedBy = 1234)
--Date filter
AND CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, dCreated))) = CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, getDate())))
GROUP BY iRecordNumber, iRecordTypeID
ORDER BY iRecordNumber
Now if I understood sargeable and I was to use an index on dCreated for that query it would totally ignore the index. But I'm not sure how to improve it, I just need to get todays record from a datetime ignoring the 'time' part on both side.