Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Forcing different Query plans based on Stored Procedure Parameter Value

$
0
0

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


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>