Skip to main content

A Closer Look at "Statistics" in an SQL Server Sense--And Why They're So Important to Microsoft Dynamics NAV Users

by Jörg A.
Consultant,

There is the proverb "Never trust a statistic which you haven't faked yourself". Well, as SQL Server is as human as the next guy, this saying applies quite well ...

But what are these ominous statistics and what they are used for? The official definition for "statistics" in a SQL Server sense is: "Statistics for query optimization are objects that contain statistical information about the distribution of values in one or more columns of a table or indexed view".

Let's translate this into English. The "distribution of values in a column" actually mean, how many different values could be distinguished for that column. For example, if a "Sales Line" record has a field "Document Type" (values Quote, Order & Invoice) and contains 100 Quotes, 100 Orders and 100 Invoices (= total 300 records), a statistic on this "Document Type" would tell that the average distribution of the field values is about 33%. In SQL Server terms this would also be called the density of the values, in this example "Document Type" has a density of 0.33. The higher the density the more same values exist in the column/field, thus, a density of 1.00 would mean that all records have the same value in that column.

The "density" could be checked with the DBCC SHOW_STATISTICS command.

Another frequently used term according to this is "selectivity", which actually is quite the opposite of "density". A high "selectivity" means, that there are many different values in a column, hence the column has a low "density". Or the other way around: if ...

FREE Membership Required to View Full Content:

Joining MSDynamicsWorld.com gives you free, unlimited access to news, analysis, white papers, case studies, product brochures, and more. You can also receive periodic email newsletters with the latest relevant articles and content updates.
Learn more about us here

About Jörg A.

Jörg A. Stryk has worked with Microsoft Dynamics NAV since 1997, version 1.20.

Being project-manager, consultant, administrator, developer or supporter on Microsoft partner-sites and NAV customer-sites, he has thoroughly explored nearly all areas of the application and its technology.

Since 2003 he is focusing on "Dynamics NAV & SQL Server Performance Optimization and Troubleshooting", founding his company "STRYK System Improvement" in 2006. As a freelance consultant, he is supporting Microsoft Dynamics partners and customers with their NAV/SQL projects worldwide.

His book "The NAV/SQL Performance Field Guide" (ISBN 978-3-8370-1442-6) is published in Europe, the United Kingdom and North America.

In recognition of his valuable participation in various NAV communities, he received the Microsoft award "Most Valuable Professional" (MVP) for MS Dynamics NAV in 2007, 2008 and 2009.

Visit Jörg Stryk at www.stryk.info or his BLOG http://dynamicsuser.net/blogs/stryk/

More about Jörg A.