Click here to monitor SSC
Av rating:
Total votes: 32
Total comments: 4


SQL Server Statistics
23 November 2010

Holger Schmeling’s work in SQL Server Distribution Statistics was first published as a pair of long articles for Simple-Talk. The booklet takes a practical, and well-informed approach to a subject that is not always easy to explain or understand.

A Distribution Statistics object is a sampled map of the distribution of data in a table. Such statistics help the Query Optimizer of SQL Server's Database Engine to translate the 'logical' SQL Query into the best strategy for doing all the physical operations of joining, sorting, and selecting  the data. Most of the time, this work happens effectively without the database administrator having to be aware of what is going on, but occasionally, if the statistics no longer reflect what is actually in the table, then queries can suddenly run grindingly slow. At this point, the DBA must intervene to correct the problem.

Holger divides his work into two parts. In the first part, he explains what ‘statistics’ are, why they are there, how they are created, updated and removed. He shows how to inspect them and to maintain them. In the second part, he lists all the problems that are related to these statistics objects, and how to solve them.

DBAs and Database developers need a reasonable understanding of distribution statistics so as to be prepared for those occasions when things go wrong. SQL Server Distribution Statistics are used by the Query Optimizer to translate what the user has declared to be his wishes for a result, the SQL, into a ‘physical’ strategy that is quick and economical for the database. The relative performance of the various ‘Physical’ strategies for executing the query will vary according to the quantity and distribution of the data within the tables. The Query optimizer uses the statistics to work out the relative merits of the possible strategies. When the statistics are outdated, or missing then queries will miss out on the best strategy for execution and can, at the worst, will get assigned a disastrously poor strategy.

Reading Holger’s booklet is a great way of brushing up on the subject of Statistics and query-optimization. It is reasonably short, and geared to the practitioner rather than the theoretician. It is careful to stick with the things you need to know, and resists the temptation to launch into discourses on the esoteric science of query optimization. For this we are all grateful.

The PDF file can be downloaded from the Red Gate website. A free EPUB version is available to download for Simple-Talk site members here.



This article has been viewed 7369 times.
Holger Schmeling

Author profile: Holger Schmeling

Holger Schmeling is a SQL Server Consultant based in Munich, Germany. He has been working with SQL Server since 1996 (Version 6.5) and has used it in many projects as a developer, administrator, database architect and designer. Occasionally he also gives classes on SQL Server development, administration and tuning. Holger has written two books on SQL Server development and performance tuning: 'Datenbankentwicklung mit dem Microsoft SQL Server 2005' and 'SQL Server 2008-Performance-Optimierung: Das Praxisbuch für Entwickler und Administratoren.' Holger's primary interest is SQL Server performance tuning. If he finds the time, he also blogs every now and then. Holger's website can be found at http://www.sqlserver-online.com.

Search for other articles by Holger Schmeling

Rate this article:   Avg rating: from a total of 32 votes.


Poor

OK

Good

Great

Must read
 
Have Your Say
Do you have an opinion on this article? Then add your comment below:
You must be logged in to post to this forum

Click here to log in.


Subject: Thanks
Posted by: FabricioLimaDBA (view profile)
Posted on: Tuesday, November 23, 2010 at 8:17 AM
Message: Thanks for this handbook.

Subject: Additional request
Posted by: nbotes (view profile)
Posted on: Wednesday, January 19, 2011 at 6:39 AM
Message: Great book Holger!

Any chance of sharing the scripts as a separate download please? I'm having problems with copy-paste from the e-book.

Thanks!

Subject: Additional request
Posted by: nbotes (view profile)
Posted on: Wednesday, January 19, 2011 at 7:24 AM
Message: Great book Holger!

Any chance of sharing the scripts as a separate download please? I'm having problems with copy-paste from the e-book.

Thanks!

Subject: The scripts
Posted by: Andrew Clarke (view profile)
Posted on: Thursday, January 20, 2011 at 5:13 AM
Message: We now have the code in the speech-bubble at the top of this description of the book

 



recommended site pinvoke

PInvoke.net is a user-driven wiki which provides .NET developers with native method signatures, so they don't have to spend time writing them from scratch.




Top rated articles
Captain Biplane: Interplanetary Airman
 Simple-Talk caters for the lighter side with its publication of 'Captain Biplane: Interplanetary... Read more...

Don't Just Roll the Dice - eBook Download
 Neil Davidson has created a short handbook with the theory, practical advice and case studies, to... Read more...

Defensive Database Programming
 Inside this book, you will find dozens of practical, defensive programming techniques that will improve... Read more...

Simple Talk Newsletter
 As an experiment, we are publishing the newsletter in an alternative eBook format so that it can be... Read more...

SQL Server Tacklebox
 Inside the SQL Server Tacklebox you'll find day-to-day tools, scripts and techniques to automate and... Read more...

Most viewed articles
Exchange 2010 - A Practical Approach
 Jaap's Practical Guide to Exchange Server 2010 draws upon all that experience to deliver an easy-to-use... Read more...

Brad's Sure Guide to SQL Server Maintenance Plans
 Brad's Sure Guide to Maintenance Plans shows you how to use the Maintenance Plan Wizard and Designer to... Read more...

Inside the SQL Server Query Optimizer
 This book will take you from the fundamentals of Statistics, Cost Estimation, Index Selection, and the... Read more...

SQL Server Hardware
 SQL Server Hardware will provide the fundamental knowledge and resources you need to make intelligent... Read more...

Simple Talk Newsletter
 As an experiment, we are publishing the newsletter in an alternative eBook format so that it can be... Read more...

Over 400,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.

Join Simple Talk