Thursday, 11 October 2018

SSMS 18.0 - Actual vs Estimated Rows

Last week Microsoft released SQL Server Management Studio 18.0 into public preview, here's a link so you can read about the new and improved functionality it offers.

One significant change is the addition of actual vs estimated row counts onto the showplan operators in execution plans (only actual, not estimated...which kinda makes sense).

Here I'm running a very simple bit of code on some DMV's (namely exec requests and sessions) to demonstrate this addition.

Here's an execution plan in a previous version of SSMS:

But in new SSMS we get some extra info:

If we look at the Table Valued Function on the far right of the plan (because that's where plans start) we can see a time statistic (0.00s) and under that "69 of 70 (98%)", hovering over the operator to bring up the tooltip shows what the numbers mean:


We can see here for this operator that the actual number of rows is 69 whilst the estimated was 70 (a 98% accuracy) so any skew in row counts are now much more visible, this is really useful when it comes to really big numbers in execution plans.



In this example (from the same query) we've got the actual number of rows displayed correctly (2) but its estimated value doesn't match what is seen in the tooltip (69 vs 8.3666). Worth noting that the values do get rounded so 8.3666 would be displayed as 8. 

Originally I thought it had got the 69 in the tooltip wrong but in looking for a bug I'd actually missed the glaringly obvious; because SQL Server has to times rows by the number of operator executions; 8.3666 x 8.30662 = 69, so no bug, just me not looking hard enough!

I like this release of SSMS, I really do and despite all my love for Operations Studio, now renamed to Azure Data Studio it's great to see the continued development of Management Studio.

2 comments:

  1. Isn't the 69 a calculation of est number of executions (8.3666) * est number of rows (8.30662) ...?

    ReplyDelete
    Replies
    1. Oh yes of course it is; completely missed the rather obvious there. I've amended the post too. Cheers Chris :-)

      Delete