October 15, 2009 at 4:41 am
Hi,
I have some procedures which perform data selects however above the actual SELECT statement there maybe a statement to check if some condition is true or false and based on that return out of the procedure (not running the SELECT).
This got me thinking (a dangerous thing for me to do) about how this would affect the execution plan.
In that if we run the procedure and it returns out and doesnt run the SELECT statement then we have a cached plan, however when it runs the next time and it does run this SELECT is that plan valid (and optimal).
In short when SQL builds it's plan for the first time is it aware of the SELECT below and is it picking the correct plan.
I've attached a sample script to show what I mean.
Thanks in advance.
October 15, 2009 at 6:13 am
Is this what you're asking about?
http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/
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
October 15, 2009 at 6:18 am
Hi Gail,
Yeah thats great.
Many thanks.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply