July 11, 2014 at 5:29 am
Yes.
Recompile allows, among other things, variables to be 'parameter sniffed'. That can be enough to start the optimiser searching in a different area of the plan space, resulting in a different plan.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 11, 2014 at 6:08 am
But she's talking about variables within the query, not parameters. Parameters are sampled by default, variables can only be sampled during a recompile situation. The other issue is, if your local T-SQL is using variables and the stored procedure is using parameters, you can could get different plans then too. Again, back to parameter sniffing.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 11, 2014 at 6:18 am
Plus recompile relaxes the rules about the plan being safe for reuse, plus there's the additional visibility into table variables, probably other stuff too.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply