You created a complex stored procedure for a tax application. Monitoring the performance of your stored procedure, you have noticed that it recompiles on each execution. The cause of recompilation is a simple query statement. How can you optimize the performance of your stored procedure with minimum effort?

You created a complex stored procedure for a tax application. Monitoring the performance of your stored procedure, you have noticed that it recompiles on each execution. The cause of recompilation is a simple query statement. How can you optimize the performance of your stored procedure with minimum effort?


Answer: – Add the RECOMPILE query hint to the query statement that causes the recompilation.

(You can obtain the best performance with minimum effort by recompiling just a statement and not the complete stored procedure. Option a. is also a solution, but requires greater effort. Options b. and c. would not solve the problem.)