SQL Server 2022 has a new feature called Parameter Sensitive Plan Optimization. I don't want to turn it on for my entire database, but I have four stored procedures that I believe would benefit from this feature. According to this article on SQL Server Central, it is possible to turn it on for specific queries or stored procedures:
To enable the PSP optimization at query level, Add the query hint OPTION (USE HINT('ENABLE_PARAMETER_SENSITIVITY_OPTIMIZATION')) just before the semicolon at the end of the query or stored procedure. Run the stored procedure or query. This stored procedure or query now has the feature enabled.
However, it is unclear how to turn it on for a SP. Do they mean the semicolon on the EXEC
line (runtime), or in the SP code itself? I've done Google searches but found nothing showing an example, which leads me to believe that it is not actually possible. If not, I will have to add it to the end of each query in the SPs - not an impossible task (I've done it before), but the article left me with some hope that it could be accomplished more easily. Like maybe a new feature of 2022.