The approach SQL Server takes is to assume that each group is

most likelyto contain the overall mean (average) number of rows. This is simply the cardinality divided by the number of unique values. For example, for 1000 rows with 20 unique values, SQL Server would assume that (1000 / 20) = 50 rows per group is the most likely value.Turning back to our original example, this means that the computed count column is “most likely” to contain a value around (19614 / 575) ~=

34.1113. Sincedensityis the reciprocal of the number of unique values, we can also express that ascardinality * density= (19614 * 0.00173913), giving a very similar result.

Definitely worth a careful read.

Kevin Feasel

2017-04-13

Statistics

No Comment