I have inherited about 20 stored procedures that have every query ending in:
OPTION(RECOMPILE, OPTIMIZE FOR(@big_id = 999))
To my understanding of these options, it is telling the server to recompile this statement's execution plan every time, and telling it to use that single number to do its optimization every time as well.
So isn't it simply recompiling the EXACT SAME PLAN every time because of the "Optimize For" option?
Or am I missing some "secret sauce" in the Constant Folding that is doing something magic?
(To me it looks like it is wasting cycles with constant query recompiles)