Same query, different performance.
🧠 Root cause
SQL caches execution plans based on the first parameter.
✅ Fix Options
OPTION (RECOMPILE)
or
OPTIMIZE FOR UNKNOWN
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
Same query, different performance.
SQL caches execution plans based on the first parameter.
OPTION (RECOMPILE)
or
OPTIMIZE FOR UNKNOWN