Upload
theresa-lawson
View
215
Download
0
Embed Size (px)
DESCRIPTION
Agenda Introduction to Statistics Deep Understanding of Statistics Best Practices of Statistics
Citation preview
Statistics and Best Practices
Pinal DaveMentor | Solid Quality Indiahttp://blog.sqlauthority.com | [email protected]
About Pinal DaveSQL Server MVPFounder – SQLAuthority.comMentor – Solid Quality IndiaSQL Server Performance Tuning ConsultantRegional Mentor – Professional Association for SQL Server (PASS) MCT, MCP, MCTS, MCDBA, [email protected] , [email protected]
AgendaIntroduction to StatisticsDeep Understanding of StatisticsBest Practices of Statistics
What is Statistics?Statistics are one of the key components to help the optimizer determine the most efficient plan for a given batchBy default statistics are created for each index and any columns in the WHERE clause without indexesThe Histogram & Density information indicate how selective the data is and approximately how many rows there are for a particular value
What is Statistics (cont…)Statistics include such information as:
Time of the last statistics collection (inside STATBLOB)Number of rows in the table or index (rows column in SYS.INDEXES)Number of pages occupied by the table or index (dpages column in SYS.INDEXES)Number of rows used to produce the histogram and density information (inside STATBLOB)Average key length (inside STATBLOB) Single column histogram, including the number of steps (inside STATBLOB)
Update Statistics ThresholdsThe auto update stats event will fire based on these rules:
When table row count goes from zero to not zeroTable had less than 500 rows and there have been more than 500 changes to the leading column of the stat since the last stat updateTable had more than 500 rows and there have been at least 500 + 20% changes to the leading column in the stat since the last updateFor temp tables, the first update fires at six changes
No Stats on - Table variablesTable valued functionsCLR columns unless binary ordering
Best PracticesEnable Auto Create StatisticsEnable Auto Update StatisticsIndex Rebuild automatically updates full statisticsManual update statistics for table with huge number of rowsIf your query plan shows heavy difference between Estimated vs. Actual Rows update your statisticsUse Update Statistics Async to update table updated with bulk insertedUse Plan Hints to KEEP PLAN for temp tablesUse UPDATE STATISTICS over sp_updatestats
ContactWeb Addresshttp://blog.sqlauthority.comhttp://www.solidq.inhttp://twitter.com/pinaldave
Email [email protected]@solidq.com
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.