All the execution plans are estimated plans. All of them. There fundamentally isn’t any such thing as an “Actual” plan.

Where Do You Get Execution Plans?

There are a lot of sources for execution plans. You can capture them using extended events (or, if you must, trace). You can capture them through the Management Studio gui. You can also capture them from the SQL Operations Studio gui. You can query the cache through the DMVs and pull them in that way. You can look at plans in query store.

All these resources, yet, for any given query, all the plans will be identical (assuming no recompile at work). Why? Because they’re all the same plan. Each and every one of them is an estimated plan. Only an estimated plan. This is why the estimated costs stay the same between an estimated and actual plan, this despite any disparity between estimated and actual row counts.

I’ve blogged about this before, but it’s worth mentioning again. There are a only a few minor differences between an estimated plan and an actual plan. It’s all about the data set. What’s going on is that an actual plan can capture query metrics, which are then appended to the estimated plan. At no point is any different plan generated during this process. It’s just a plan, an estimated plan, or, it’s a plan plus query metrics.

Conclusion

Never mistake me on this, I want to see the query metrics as often as I can when dealing with execution plans. That means capturing what’s called an actual plan. However, let’s be clear, there’s nothing different in that plan except those metrics. It’s not a different plan. It’s the same plan, plus some metrics. Hopefully this helps people clarify what’s up with execution plans and will help them put a little more faith in using the estimated plans in some cases.

Want to talk execution plans and query tuning some more. I have three, full day seminars coming up.

First, in Richmond, on March 23, 2018, I’m doing a precon for SQLSaturday Richmond on the topic of tools for query tuning. Please register here.

I’m also going to be doing this same pre-con for SQLSaturday Philadelphia on April 20, 2018. You can sign up here for that event.

Additionally, I am doing this precon for SQLSaturday NYC on May 18, 2018. Go here to register for that event.

Share this: Twitter

Facebook

Reddit

LinkedIn

Tumblr

WhatsApp

Pocket

Email

