Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm migrating a ~15GB database from SQL Server 2005 to a new server running SQL Server 2008, and along with that I need to create all the new Maintenance Plans. I can take care of all the backup stuff, but the table maintenance baffles me some. Does anyone have any input on how often I should (or how often you do would suffice too) the following tasks?

  • Check Database Integrity
  • Rebuild Indexes
  • Reorganize Indexes
  • Update Statistics
  • Shrink Database?

Am I missing anything? Again if you can share how often you do these tasks that would be great...and/or share any general information about your approach to table maintenance that would be helpful. Lastly does it matter what order I run these tasks in (when setting up a job)?

Oh and I'm open to any links which might be of help!

share|improve this question

migrated from stackoverflow.com Feb 2 '12 at 0:48

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers 3

up vote 7 down vote accepted

Usually you'd do weekly or daily depending on your usage and maintenance windows.

You pretty much never shrink, especially not scheduled.

For rebuild/reorganise and statistics there are scripts (such as SQL Fool's one) that do a better job. Note: reorganise and rebuild are not exclusive but work different ways. 3rd party scripts can choose the best option (based on fragmentation).

We use weekly index/DBCC and daily statistics. And never shrink.

From Simple-talk: Don't Forget to Maintain Your Indexes

Edit: The URL is has ’ that messes up http://www.simple-talk.com/sql/database-administration/don’t-forget-to-maintain-your-indexes/

share|improve this answer
add comment

For scripts, Ola Hallengren has wicked awesome things maintenance. Use maintenance plans for now, once you become a little comfortable with the process of doing maintenance, switch to using scripts, running scheduled SQL agent jobs.

At my place of work, I am doing DBCC, reorg'ing indexes every night. On the weekends, it's DBCC, rebuild indexes, update stats.

Don't shrink anything. If you do, Brent Ozar will yell at you, it is never fun to have a SQL MCM yell at you.

share|improve this answer
add comment

Re: Shrinking. I see so many people getting their claws out at the very mention of 'shrink' and 'database' in the same sentence, so time to clear things up a little.

Shrinking data is baaaaad. It literally turns your indexes into quivering shells of their former glory. Don't do it.

Shrinking log should not be done routinely, but if you have a ridiculously outsized log (i.e. in one case I saw a 40GB log for a 100MB database, due to whoever set it up putting recovery model to full then never dumping the transaction log), you can shrink the log (after BACKUP LOG) to reclaim that space without any ill effects (although, obviously, the SHRINK will chew up I/O while it's running).

PS: Speaking of log files, check your log file size and autogrowth settings. Small autogrowth settings can lead to underperforming log I/O (due to a poorly-explained feature in SQL Server called Virtual Log Files), particularly on batch transactions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.