|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 5:46 PM
Points: 16,
Visits: 92
|
|
Greeting All: Using SQL Server 2005 (9.00.5000.00), but moving to SQL Server 2008 in 4 months. I am in the process of updating my Weekend Maint scripts.. Currently I Reindex Clustered and Non-Clustered Indexes when avg_page_space_used_in_percent < 75 and avg_fragmentation_in_percent > 10 and page_count > 100. Of those selected, if Fragmentation <=30, than I reorganize those Indexes. If Fragmentation > 30, than I rebuild those Indexes. So at the end of the Maint I have Non-Clustered and Clustered Indexes either Rebuilt or Reorganized. Also I have Clustered and Non-Clustered Indexes which were not selected that weekend to be reindexed and heap tables. After that step I usually run sp_updatestats command for the entirely database, assuming that BOL cannot lie: sp_updatestats updates only the statistics that require updating..., so, for example, Indexes, which were just rebuild in the previous step, will be skipped. But as my database gets bigger and I see more and more discussions contradicting the above extract from BOL, can someone please outline update statistics steps that needs to be done after Weekend Reindexing. Thank you, B
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:08 AM
Points: 6,706,
Visits: 11,739
|
|
inHouseDBA (6/4/2012) Greeting All: Using SQL Server 2005 (9.00.5000.00), but moving to SQL Server 2008 in 4 months. I am in the process of updating my Weekend Maint scripts.. Currently I Reindex Clustered and Non-Clustered Indexes when avg_page_space_used_in_percent < 75 and avg_fragmentation_in_percent > 10 and page_count > 100. Of those selected, if Fragmentation <=30, than I reorganize those Indexes. If Fragmentation > 30, than I rebuild those Indexes. So at the end of the Maint I have Non-Clustered and Clustered Indexes either Rebuilt or Reorganized. Also I have Clustered and Non-Clustered Indexes which were not selected that weekend to be reindexed and heap tables. After that step I usually run sp_updatestats command for the entirely database, assuming that BOL cannot lie: sp_updatestats updates only the statistics that require updating..., so, for example, Indexes, which were just rebuild in the previous step, will be skipped. But as my database gets bigger and I see more and more discussions contradicting the above extract from BOL, can someone please outline update statistics steps that needs to be done after Weekend Reindexing. Thank you, B What are you doing to the heaps?
Re: sp_updatestats, running it after your index maintenance is fine. From Books Online sp_updatestats article:
In SQL Server 2005, sp_updatestats updates only those statistics that require updating based on the rowmodctr information in the sys.sysindexes compatibility view; therefore, preventing unnecessary updates of unchanged items. If you want to make the best stats possible available to the optimizer and you have time in your maintenance window then run this after running your index maintenance to do a FULLSCAN update of all your column-level stats. Even if you do this there is still no harm in calling sp_updatestats:
USE dbname; EXEC sys.sp_MSforeachtable @command1 = N'UPDATE STATISTICS ? WITH FULLSCAN, COLUMNS;';
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 5:46 PM
Points: 16,
Visits: 92
|
|
No, I don't update Stats on heap tables. What I was thinking is to run update statistics on all tables where indexes were NOT rebuld...
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:08 AM
Points: 6,706,
Visits: 11,739
|
|
When an index is rebuilt or reorged only the stats for that index are updated. This is why I suggest also updating column statistics if you have time. If you ran these steps as often as time allows, in this order, you would have very healthy indexes and stats:
1. Your index maintenance routine. 2. The update COLUMN stats code I provided above. 3. sp_updatestats on the whole database.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 5:46 PM
Points: 16,
Visits: 92
|
|
Thank you, I guess my stopping point is the following: When you rebuild the index - you rebuild it with 100% sample size, but when you run sp_updatestats a default sampling is being used with a following formula: Rowmodctr 500 + 20% of total rows (rowcnt). So by running sp_updatestats after Index Rebuild you are already not improving those indexes, but making it even worse?!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:08 AM
Points: 6,706,
Visits: 11,739
|
|
inHouseDBA (6/6/2012) Thank you, I guess my stopping point is the following: When you rebuild the index - you rebuild it with 100% sample size, but when you run sp_updatestats a default sampling is being used with a following formula: Rowmodctr 500 + 20% of total rows (rowcnt). So by running sp_updatestats after Index Rebuild you are already not improving those indexes, but making it even worse?!
No, sp_updates stats will only update stats if underlying data has changed beyond a certain point, so if you run all this in order during low utilization it will be skipped.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 5:46 PM
Points: 16,
Visits: 92
|
|
| Thanks, so by running ...UPDATE STATISTICS ? WITH FULLSCAN, COLUMNS;.. it will also update Columns in heap tables as well, right?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:08 AM
Points: 6,706,
Visits: 11,739
|
|
inHouseDBA (6/7/2012) Thanks, so by running ...UPDATE STATISTICS ? WITH FULLSCAN, COLUMNS;.. it will also update Columns in heap tables as well, right? If the heap has column-stats on it, yes, it will update the stats.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 5:46 PM
Points: 16,
Visits: 92
|
|
| Including System Stat (or _WA_Sys_) on heap, right?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:08 AM
Points: 6,706,
Visits: 11,739
|
|
Yes. Any auto created or manually created column stats.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|