How to create sql server maintenance plan- Best Practices on Tasks and Scheduling?

865    Asked by CaroleThom in SQL Server , Asked on Apr 16, 2021


I am tasked with devising a maintenance plan for our Sql Server 2005 databases. I know for backups I want to do a daily full database backup and transactional log backups every 15 minutes. My problem comes to figuring out which other tasks I want to do and how often I should do them.


So, so far I have this in mind. Correct me if there are any flaws in my thinking or a better way to do this. Backup - All Tables, Full Backup (daily) Backup - Selected Tables, Full Backup (hourly) Backup - Transaction Logs (every 15 minutes) Check database integrity (daily) Reorganize index (daily) Update statistics (daily) Shrink database (weekly) Rebuild index (weekly) Maintenance cleanup (daily)


I remembered reading some time ago (when I set up a similar plan at another job) that some of these tasks don't need to be run on a daily basis or should not be run daily. As to which ones, it escapes me. I could use a little guidance on creating a better maintenance plan that will reduce data loss in an disaster, but won't tax the system when running during peak hours (and also increase the performance).


Answered by Clare Matthews

To create a database maintenance plan, open SQL Server Management Studio (SSMS) and connect to the SQL Server instance. Once connected to the instance, expand Management Right-click on the Maintenance Plans Select New Maintenance Plan. In the New Maintenance Plan dialog box, specify the name of the maintenance plan. This is a very common task for all DBAs and the right answer is NOT the same for every one and for each server. As lot of other things, it depends on what you need.

Most definitely you don't want to run "Shrink Database" as already suggested. Its EVIL to performance and the below ref will show you why. It causes disk and as well as index fragmentation and this can lead to performance issues. You are better off by pre-allocationg a big size for the data and log files so that autogrowth will NOT kick-in. I didn't understand your #2. selected tables full backup. Can you elaborate more on this? Coming to Index reorganize, update statistics and index rebuilds, you need to be careful on how you do this otherwise you will end up using more resources and also end up with performance issues.

When you rebuild indexes the statistics of the indexes are updated with fullscan but if you do update statistics after that, then those will be updated again with a default sample (which depends on several factors, usually 5% of the table when table size > 8 MB) which may lead to performance issues. Depending on the edition you have, you may be able to do online index rebuilds. The right way of doing this activity is check the amount of fragmentation and depending on that either do index rebuild or index reorganize + update statistics. And also you may want to identify which tables need to update stats more frequently and try to update stats more often.

Maintenance Plans are OK but its hard to get the best out of them doing these customizations unless you can login to SSIS and tweak the MP's. that's why I prefer NOT to use them and use Ola Hallengren's free scripts that are more robust than MP's. Also, I would recommend to catch up on the referenced article by Paul Randal on this topic. Ref: http://technet.microsoft.com/en-us/magazine/2008.08.database.aspx This is NOT a comprehensive answer to your question but a good starting point. HTH and let us know if you have any additional questions/comments.


Your Answer

Interviews

Parent Categories