I have a stored procedure that contains some Select statements that return union result of them.
I think and write one select instead of several Select and want to compare EXECUTION PLAN of them (SP and one Select statement).
the problem is when run this twe statement(SP and Select) all select statement in sp have their execution plan.I want to have execution plan of SP as an UNIT.
I have another question.Consider execution plan that attached to this post.Is sum cost of an execution plan for all statement must be 100%?
But why sum cost of all statement of this execution plan not be 100%?
thanks
If you are trying to compare two versions of the logic then a script along the lines of:
Will let you do it. Yes the execution plan will show you all of the queries inside the stored proc. Look for the plans for the queries that occur outside of the SP. If they give a total cost > 50% then the SP performed better.
As a side note, if your SP takes parameters make sure you compare the execution plans across a range of parameter values.