Download presentation
Presentation is loading. Please wait.
1
Pinal Dave Mentor | Solid Quality India http://blog.sqlauthority.com | pdave@solidq.com
2
About Pinal Dave SQL Server MVP Founder – SQLAuthority.com Mentor – Solid Quality India SQL Server Performance Tuning Consultant Regional Mentor – Professional Association for SQL Server (PASS) MCT, MCP, MCTS, MCDBA, MCAD pdave@solidq.com, pinal@sqlauthority.com
3
Agenda Introduction to Statistics Deep Understanding of Statistics Best Practices of Statistics
4
What is Statistics? Statistics are one of the key components to help the optimizer determine the most efficient plan for a given batch By default statistics are created for each index and any columns in the WHERE clause without indexes The Histogram & Density information indicate how selective the data is and approximately how many rows there are for a particular value
5
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)
6
Update Statistics Thresholds The auto update stats event will fire based on these rules: When table row count goes from zero to not zero Table had less than 500 rows and there have been more than 500 changes to the leading column of the stat since the last stat update Table had more than 500 rows and there have been at least 500 + 20% changes to the leading column in the stat since the last update For temp tables, the first update fires at six changes No Stats on - Table variables Table valued functions CLR columns unless binary ordering
7
Best Practices Enable Auto Create Statistics Enable Auto Update Statistics Index Rebuild automatically updates full statistics Manual update statistics for table with huge number of rows If your query plan shows heavy difference between Estimated vs. Actual Rows update your statistics Use Update Statistics Async to update table updated with bulk inserted Use Plan Hints to KEEP PLAN for temp tables Use UPDATE STATISTICS over sp_updatestats
8
Statistics All about Statistics
9
Contact Web Address http://blog.sqlauthority.com http://www.solidq.in http://twitter.com/pinaldave Email Address pinal@sqlauthority.com pdave@solidq.com
10
© 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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.