Sql-server – DBCC show_statistics: density doesn’t match what I calculate

sql serversql-server-2005

I've read in several articles that the density of a column is (1.0 / count(distinct columnname)). I have a column with roughly 2.6 million distinct values over 2.7 million rows, but the column density in DBCC show_statistics even AFTER updating statistics with fullscan is .48.

I am confused as to where this number could be coming from. Can anyone explain it to me?

Best Answer

The documentation for DBCC SHOW_STATISTICS says that Density (in the header) is:

Calculated as 1 / distinct values for all values in the first key column of the statistics object, excluding the histogram boundary values.

It also says:

This Density value is not used by the query optimizer and is displayed for backward compatibility with versions before SQL Server 2008.

You are using SQL Server 2005, so this value may be relevant to you in some circumstances, but I don't know exactly when 2005 would use that Density value.