Site sponsored by: Idera The gold standard of SQL Server performance monitoring & diagnostics.
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

System Data Collection Reports
Recover Data Using Database Snapshots
Analyze and Fix Index Fragmentation in SQL Server 2008
Powerful Geographical Visualisations made easy with SQL 2008 Spatial (Part 2) ...

More     
 
Latest FAQ's

How to alter a User Defined Data Type?
How to unzip a File in SSIS?
How to view previous query plans?
ALTER TABLE SWITCH statement failed because the object '%.*ls' is not ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Doc 2008
ApexSQL Enforce
Embarcadero Change Manager
SQL Server DBA Dashboard

More     

articles >> performance tuning >> Automating Reindexing In SQL Server 2000 ...

Automating Reindexing In SQL Server 2000

By : Tom Pullen
May 04, 2005

Page 4 / 4


The above is a screenshot of the output text file from this SP opened in Excel. Some columns have been deleted for the sake of brevity. When opening it, you need to follow the open Text File wizard – chose Fixed width and open the Import at Row 3.

Here, you can review the scan densities of the tables in your database which have been checked.

Further down the output file (after the data output from DBCC SHOWCONTIG), you will find the text output which details which tables and which of their indexes are being reindexed, with the start and finish times of the reindexing section at the beginning and end of this part. An example is shown below.

 

Why Not Use DBCC INDEXDEFRAG() to Reduce Blocking?

The answer is, use it if you want or need to! If your requirements are 24X7 operations and the exclusive table locks that DBCC DBREINDEX() take are unacceptable to your business, you can substitute it for DBCC DBREINDEX(). However, you will need to adapt the syntax as they are not the same (thanks, Microsoft!). If you do not know the difference, here is a brief summary: DBCC DBREINDEX() is a complete, through, bottom-up index recreation operation which will exclusively lock the table while it runs by necessity. DBCC INDEXDEFRAG() is a less complete, but online operation, which will attempt to improve your indexes’ condition as far as it can while not causing blocking and (hopefully) not disrupting OLTP. I must admit I have never used DBCC indexdefrag(), as my systems do not have strict 24X7 no-blocking requirements, fortunately, so I cannot vouch for is efficacy or otherwise. I have read that it is not as effective as a full DBCC DBREINDEX. However, it will surely be better than nothing, so if your database runs a global website which must never stop, as is common nowadays, you should adapt this stored procedure to use it instead.

 

Add it as a Scheduled Task

This is a relatively trivial task for a moderately experienced DBA, so I will not include code for it here. Add it as a stand-alone task or include it as a step in your existing maintenance job. Make sure you set the job-step or job to output to a text file so you can retain and look at the all-important output file.

 

Conclusion and Summary

Hopefully, this code and article will help you to achieve a better and more refined approach to your database server maintenance. Maintenance windows nowadays are precious commodities and should be kept to an absolute minimum in terms of both impact on users and duration whilst also preserving an efficient and well-maintained database server. Implementing this procedure as a scheduled task, with careful monitoring of its output, should help you, to some degree; achieve your ends more effectively.


 

Tom Pullen has been a DBA for 6 years. He currently works for Oxfam, a large UK charity. He has experience in SQL Server 6.5, 7.0 and 2000. He is married with two children. Contact him at: tpullen@oxfam.org.uk

Copyright 2004 by the author.


<< Prev Page         








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved