Member Login
  • Products
    • Qure Suite
    • Qure Analyzer
    • Qure Optimizer
  • Downloads
    • Qure Analyzer (Free)
    • Qure Optimizer (Free Trial)
  • Support
    • Contact Support
    • Frequently Asked Questions
    • Limitations and Known Issues
  • Resources
    • Qure Optimizer Resources
    • Qure Analyzer Resources
    • Whitepapers
    • Videos and Tutorials
    • eBooks
    • Attend an Online Demo
    • inTune eMagazine
    • SQL Server Tuning Blog
  • Learn More
    • About Workload Tuning
    • SQL Server Tuning
    • SQL Server Performance
    • SQL Server Performance Tuning
    • Tips
    • SQL Server Articles
  • Company
    • About DBSophic
    • Management
    • Partners
    • News
    • Success Stories
    • Customer Testimonials
    • Selected Customers
  • Contact Us
Subscribe to blog

SQL Server Tuning Blog

By SQL Server MVP Ami Levin

Posted by Ami Levin
Ami Levin
My name is Ami Levin, and I've been working with SQL Server for over 15 years. I
User is currently offline
on Wednesday, 25 April 2012
in SQL Server Tuning
  • Hits: 1568
  • 0 Comments
  • Subscribe to updates
  • Print
  • Bookmark

Index rebuilds and statistics updates

Tweet

An interesting discussion came up lately on the MVP private forums regarding index rebuilds, recompilation and statistics updates. Although the debate spanned too many aspects for me to cover here in this short post, I think that one important point should be emphasized as it might be making you do redundant work or even worse - unknowingly degrade the performance of your workload.

When you rebuild an index, a full scan of all index keys is performed. SQL Server uses this opportunity not only to rebuild the index, but also to update the related statistics. What is unique about this statistics update is the fact that it is equivalent to an update with the full-scan option. The default statistics sampling uses only a small fraction of the keys in order not to load your production server. A statistics based on a full scan of the data has the potential to be more accurate, therefore provide the query optimizer with better information, allowing it in turn to produce better performing execution plans for your workload queries. Also remember that a statistics update flushes all plans that use it from the procedure cache forcing a recompilation of the related queries.

Therefore, note the following tips:

 

  • After rebuilding an index, there is no need to updates its statistics explicitly. Moreover, doing so might actually get you less accurate statistics if you fail to use the FULL SCAN option.
  • After rebuilding an index, there is no need to explicitly flush the relevant plans from cache. They will be flushed automatically. Be aware that using more 'aggressive' means like executing sp_recompile on the underlying table or flushing the cache altogether might cause unexpected results as additional plans, ones that had nothing to do with your rebuilt index, will be recompiled again.
  • If you have the time window during off-peak hours, try updating statistics of your larger tables using the FULL SCAN option. In some cases, it can make a huge difference.

Have a great weekend!

 

0 votes
Tags: Maintenance, Performance, Statistics
  • About the author
  • Related Posts
Ami Levin
My name is Ami Levin, and I've been working with SQL Server for over 15 years. In 2006 I was awarded the SQL Server MVP award.I am also the CTO (and co-founder) of DBSophic. I hope you will find this blog interesting and useful. Your feedback will be highly appreciated.
  • View author's profile
  • Subscribe to blogger updates
  • Variable Size Data Types and Memory Grants

    Yesterday, at our 118th Israeli SQL Server User Group Meeting, Adi Cohn delivered a session on common performance pitfalls. One of the issues he menti...
    By Ami Levin on - May 08 in SQL Server Tuning

Comments

Please login first in order for you to submit comments

Biography

Ami Levin
My name is Ami Levin, and I've been working with SQL Server for over 15 years. In 2006 I was awarded the SQL Server MVP award. I am also the CTO (and co-founder) of DBSophic. I hope you will find this blog interesting and useful. Your feedback will be highly appreciated....
View all posts

Latest Posts

  • EZManage SQL vendor and developer announced the acquisition of the fast growing company DBSophic.
    The acquisition will expand the acquiring company's solutions for the applicative environment of MS
    Read More
  • A Month of Joins - T-SQL Tuesday #37
    T-SQL Tuesday is now entering its fourth year! Sebastian Meine, who's hosting this month's T-SQL Tue
    Read More
  • Where did I leave my keys?
    "If you walk into a room full of DBAs or DB developers and you feel like having the same kind o
    Read More

Tag Cloud

Maintenance EZManage sql TSQL2sDay installation Performance Announcements data types SSDT SQL Server 2012 MVP Qure Analyzer HA/DR Statistics hardware Performance Articles Presentations common pitfalls Statistics DBsophic SQL Graphics Publications RTM iPad

Blog Calendar

Loading ...
© 2011 DBSophic Ltd. All rights reserved. | Legal