Hi, I am trying to gather knowledge on what my fellow db devs do to handle these scenarios.Because of the skewed data nature, for certain parameter values, INDEX SCAN is the optimum operation but for other parameter values INDEX SEEK is efficient operation.But the stored procedure picks up the existing query plan and re-uses it. I can enforce RECOMPILE option to create new plan .I also played with OPTIMIZE FOR hint with specific values as well as UNKNOWN value.
End of the day , I want to force a plan based on the parameter value but don’t want to incur recompile cost every single execution.I am also toying with the idea of creating separate procedures.
I am wondering what other folks do to solve these scenarios. I appreciate your help.
Cheers
I90Runner