Quiz: Guess the Statistics Estimate

Think like the SQL Server optimizer

  • You have a picture of the header, density vector, and an excerpt of the histogram for a statistic. (The screenshot includes everything you need.)
  • You then get to see queries and procedures with predicates on the column described by that statistic.

Your job: guess how many rows the queries will estimate using the statistic given.

Assume this code is run against the WideWorldImporters database in SQL Server 2017 (download info in the code link below), and that the database is using the new cardinality estimator.

Click to see a larger image

Quiz: Statistics - Guess the Statistics Estimate 💯

  • Assume this is the first execution of the procedure after it has been created.
  • Assume this is the first execution of the procedure after it has been created.
  • Assume this is the first execution of the procedure after it has been created.

Want to generate the estimates in execution plans?

Grab the code here, and go for it!

Not quite ready for this quiz yet?

If you’re not sure what statistics are, or where to begin, browse some background on statistics in my article here — but don’t read the whole thing, just the parts about what statistics are and how they are created.

Then, come back, take the quiz, and guess. Read the explanations in the answers and examine the pictures, and that will help you learn how it works.

Want more quiz questions on statistics?

Take my first quiz on stats here.