This looks innocent:
WHERE DATEDIFF(day, CreatedAt, GETDATE()) = 0
β Why itβs bad
-
Forces full scan
-
Index becomes useless
β Fix
WHERE CreatedAt >= CAST(GETDATE() AS date)
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
This looks innocent:
WHERE DATEDIFF(day, CreatedAt, GETDATE()) = 0
Forces full scan
Index becomes useless
WHERE CreatedAt >= CAST(GETDATE() AS date)