Database maintenance plan - recommendation

Hi
I have an existing mm plan in one of the server which contain 
1.Check integrity 
2.Shrink 
3. Reorganize 
4.Rebuild 
5.Update stats 
Does both Reorganize and Rebuild required in the same mm plan ? Only Rebuild will optimize the indexes ? 
Currently re-org is taking 2 hrs to complete where Rebuils only 20 min . 
Thanks  

2 Shrink -
The second option Shrink is not recommened in a maintenance plan. Shrinking introduces fragmentation and causes autogrowth unnecessarily. Shrinking in not a good for either data file or log files. Shrinking occassionally to free up space which got increased
exponentially due to some specific operation is fine. But shrink in a Maintenance plan is a very very bad idea. Check these blogs
http://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/07/27/oh-the-horror-please-stop-telling-people-they-should-shrink-their-log-files.aspx
3 Reorganize/4 Rebuild
Both are not required. Either one is enough. A better approach is to find the fragmentation and then decide either to reorganize or rebuild. You dont have to do this for all indexes. You only need to reorg/rebuild if the fragmentation is higher. General
rule of thumb
Fragmentation between 10 % - 30 % - Reorganize
Fragmentation above 30 % - Rebuild
Also you only need to do this if the page count is above 1000.
I would recommend you to take a look at Ola Hallegrans maintenance solution rather than using a Maintenance Plan
https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
https://ola.hallengren.com/sql-server-integrity-check.html
Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

Similar Messages

  • SQL 2000 Database Maintenance Plan drop downs for days, weeks, months, not displaying

    When setting up a SQL 2000 Database Maintenance Plan the drop down for Remove files older than is not populating with hours, days, weeks, or months. It is just blank. The version is  Microsoft SQL Server  2000 - 8.00.2039 (Intel X86)  
    May  3 2005 23:18:38   Copyright (c) 1988-2003 Microsoft Corporation  Desktop Engine on Windows NT 5.2 (Build 3790: Service Pack 2). Is there a fix for this issue?

    This also works. All the credit goes to a user named eyechart.  Great directions provided as well.
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47575
    sqlmaint.exe
    was missing from MSDE 2000, but that was fixed in SP1 I think. Since this is SP3
    you probably have a missing registry value for the backup directory.
    I
    had to fix a similar problem last year on a bunch of laptops. They were all
    missing a registry value. Anyway, here is the fix:
    1. Fire up regedit and
    look under HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer
    2. Ensure you have
    a string value called BackupDirectory. The value for this should be the path to
    your backup dir. The default value is C:\Program Files\Microsoft SQL
    Server\MSSQL\BACKUP
    btw, this fix assumes you have a default instance
    installed. A named instance will have slightly different registry location and
    filesystem path.
    -ec
    Edited by -
    eyechart on 03/25/2005 21:04:27

  • Developing a Database maintenance plan

    Can you provide me links which goes into detail about developing a Database maintenance plan[i.e. taking backups [either Full or Inc] of DBs and transaction logs, deleting the oldest cycles, etcc]. I am not a DBA but at same time I am trying to learn as
    much as I can.

    Refer
    http://ola.hallengren.com/
    http://www.sqlservercentral.com/articles/Stairway+Series/72462/
    -Prashanth

  • Maintance jobs with Maintenance plans - troubleshooting

    Some of our old servers have maintenance jobs created with inbuilt mainteance plans. We find difficulty in troubleshooting these kind of jobs when it fails. Can anyone shed a detailed analysis of how to troubleshoot these jobs which are created with maintenance
    plan like where to look, any system table/view that could help etc. The job history gives very minimal details and often result in cropped off messages.
    I was told that if we alter the maintenace plans associated with the jobs and save it. It will break the job, is it so?

    For SQL server 2000
    You can check the failure logs either from jobs or Maintenance plan history
    In enterprise manager, expand the server group
    Expand the management folder and select the database maintenance plans
    Right click the maintenance plan that failed and select the Maintenance plan history
    Check for the failure occurred and double click the failed row to see more details or on failure
    Similarly from SQL server 2005 onwards maintenance plan history, you can check from maintenance plan
    In SSMS, connect to SQL instance
    Expand the Management folder and select the maintenance plans
    Select the maintenance plan and click on maintenance plan history and check for the failure
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • Database maintenance for sqlserver database to improve performance

    In our company sqlserver 2008 R2 is working as a project server database.
    I want to know commands for database maintenance.
    Please let me know all command in order which i need to run in sqlserver for database maintenance.
    because i want to increase performance of projectserver 2010.

    Hi John.Eddie,
    For increasing SQL Server performance, you can do full daily backup, transaction log backups, check database integrity, rebuild index and update statistics in database maintenance plan.
     However, you need to note that running "Shrink Database", it causes disk and as well as index fragmentation and leads to performance issues.
    To ensure your database stays healthy and available, there are a few "'must do" tasks. For example:
    1.Remove excessive transaction log file fragmentation.
    2.Set auto-growth correctly.
    3.Turn off any scheduled shrink operations.
    4.Turn on AUTO_CREATE_STATISTICS and AUTO_UPDATE_STATISTICS, plus have a regular process in place to update statistics.
    5.Have a regular process to run DBCC CHECKDB, take full database backups, plus differential and log backups for point-in-time recovery.
    For more information about database maintenance, you can review the following article.
    http://technet.microsoft.com/en-us/magazine/2008.08.database.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Query to get details from Maintenance plans

    Hi All,
    Could some one please let me know, if there is any way to check whether
    all  databases option is selected under the maintenance plan other than using GUI. Below is the print screen for reference.
    Maintenance plan includes rebuild Index, checkdb and  update statistics steps, I have to check whether the All databases option is selected for each individual task.
    I have a requirement wherein, I have to check this thing on around 5000 servers.
    It would be great if someone lets me know the script to check this setting, so that it will save my time.
    I have used below queries and tables to get the data, but they don't have the information which i'm looking for
     sysdbmaintplan_databases
    Contains one row for each database that has an associated upgraded database maintenance plan.
    sysdbmaintplan_history
        Contains one row for each upgraded database maintenance plan action performed.
    sysdbmaintplan_jobs
        Contains one row for each upgraded database maintenance plan job.
    sysdbmaintplans
        Contains one row for each upgraded database maintenance plan
        select * from sysdbmaintplan_jobs
        SELECT name,subplan_name,subplan_description
        FROM msdb.dbo.sysmaintplan_plans AS s
        INNER JOIN msdb.dbo.sysmaintplan_subplans AS sp ON sp.plan_id=s.id
        Order by name,subplan_name
     SELECT s.name AS MaintenancePlanName,
    sp.subplan_name AS SubplanName,
    subplan_description AS SubplanDescription,
    sj.name AS JobName,
    sj.enabled AS JobStatus,
    ss.name AS ScheduleName
    FROM msdb.dbo.sysmaintplan_plans AS s
    LEFT JOIN msdb.dbo.sysmaintplan_subplans AS sp ON sp.plan_id = s.id
    LEFT JOIN msdb.dbo.sysjobs AS sj ON sj.job_id = sp.job_id
    LEFT JOIN msdb.dbo.sysschedules AS ss ON sp.schedule_id = ss.schedule_id
    ORDER BY s.name,
    sp.subplan_name
    Thanks in Advance.
    Regards, Kranthi

    On a different note,  i think you can script the maintenance plan - ssis package and then insert into sysssiscatalog table and i think this will create the ssis - maintenance plan on the server. not sure ..this is just thought.... they can be compatibility
    issue.
    also, you can use the history - maintenance plans to get the data you need. but the caveat is the maintenance plan should have and history should exist and 'extended log  information' must be checked on the plan. this can be done - checking a text box
     in the plan properties.
    try this query.. i used top 1 ..so, you can try... if all databases are used in the plan..it will just show all  but if only some are used, i split that into multiple rows,(you might not need this)..there are some many other combinations possible,,
    such selecting on some tables etc...  you can query all that information from history tables, 
    try this query 
    use msdb
    go
    select top 1 @@SERVERNAME [servername],case when d.Succeeded=1 then 'Success' when d.succeeded=0 then 'Failed' End as Result,
    name,b.subplan_name,D.line1,D.line2,replace(D.line3,'Databases: ','') as [DBs],D.line4,D.line5,D.start_time,D.end_time,D.command,d.Succeeded
    into #test
    from sysmaintplan_plans a inner join sysmaintplan_subplans b on a.id=b.plan_id
    inner join sysmaintplan_log c on c.plan_id=b.plan_id and c.Subplan_id=b.subplan_id
    inner join sysmaintplan_logdetail d on d.task_detail_id=c.task_detail_id
    ORDER BY D.start_time DESC
    GO
    SELECT [ServerName],name,subplan_name,line2,
    Split.a.value('.', 'VARCHAR(100)') AS String
    FROM (SELECT [ServerName],name,subplan_name,line2,
    CAST ('<M>' + REPLACE([DBs], ',', '</M><M>') + '</M>' AS XML) AS Dbs
    FROM #test) AS A CROSS APPLY Dbs.nodes ('/M') AS Split(a);
    drop table #test
    anyways, on a side note, if you really have 5000 sql servers, you should looking at some tool or scripts to do this maintanence tasks than the builtin maintenance tasks as they provide better managebility. also, it is highly likely that you have multiple version,
    which makes it even harder to script out....
    Hope it Helps!!

  • IF Auto Update Statistics ENABLED in Database Design, Why we need to Update Statistics as a maintenance plan

    Hi Experts,
    IF Auto Update Statistics ENABLED in Database Design, Why we need to Update Statistics as a maintenance plan for Daily/weekly??
    Vinai Kumar Gandla

    Hi Vikki,
    Many systems rely solely on SQL Server to update statistics automatically(AUTO UPDATE STATISTICS enabled), however, based on my research, large tables, tables with uneven data distributions, tables with ever-increasing keys and tables that have significant
    changes in distribution often require manual statistics updates as the following explanation.
    1.If a table is very big, then waiting for 20% of rows to change before SQL Server automatically updates the statistics could mean that millions of rows are modified, added or removed before it happens. Depending on the workload patterns and the data,
    this could mean the optimizer is choosing a substandard execution plans long before SQL Server reaches the threshold where it invalidates statistics for a table and starts to update them automatically. In such cases, you might consider updating statistics
    manually for those tables on a defined schedule (while leaving AUTO UPDATE STATISTICS enabled so that SQL Server continues to maintain statistics for other tables).
    2.In cases where you know data distribution in a column is "skewed", it may be necessary to update statistics manually with a full sample, or create a set of filtered statistics in order to generate query plans of good quality. Remember,
    however, that sampling with FULLSCAN can be costly for larger tables, and must be done so as not to affect production performance.
    3.It is quite common to see an ascending key, such as an IDENTITY or date/time data types, used as the leading column in an index. In such cases, the statistic for the key rarely matches the actual data, unless we update the Statistic manually after
    every insert.
    So in the case above, we could perform manual statistics updates by
    creating a maintenance plan that will run the UPDATE STATISTICS command, and update statistics on a regular schedule. For more information about the process, please refer to the article:
    https://www.simple-talk.com/sql/performance/managing-sql-server-statistics/
    Regards,
    Michelle Li

  • Maintenance plan for SQL Server 2012 Database in AlwaysOn Availability Group

    Hi all,
    I need assistance creating a maintenance plan that will backup a databases logs in order to prevent them from filling up the drive they are located on. I have looked at some blogs but they do not specifically show how this is done.
    My database is in an AlwaysOn Availability Group.
    Thank you very much for your help!
    Jake

    Hi all,
    I need assistance creating a maintenance plan that will backup a databases logs in order to prevent them from filling up the drive they are located on. I have looked at some blogs but they do not specifically show how this is done.
    My database is in an AlwaysOn Availability Group.
    Regular maintenance plan would work. Only thing to remember is that when you create log backup plan, there is a checkbox which says whether it should honor backup preference or not.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Database updates statistics maintenance plan issue.

    Hi team,
    We are configured one job through maintenance plan that job name is “database update statistics” and database size is 280 Gb, this job executing 13 to 15 hours but job was not finished  still it’s continually running.
    This same job I am running through below script it’s executing within 2 hours.
    Use database
    Go
    Exec sp_updatestats
    What is the main problem if this maintenance plan.
    Note: on this server no jobs and no traffic, only abc_update subpaln1 Job.

    Hello,
    Updating stats for whole database which is 280 G will always result in problem.It is better to run update statistics for tables and indexes which are changed frequently.
    Now to your question few points which sp_Updatestas list in BOL
    http://technet.microsoft.com/en-us/library/ms173804.aspx
    sp_updatestats updates statistics on disabled nonclustered indexes and does not update statistics on disabled clustered indexes.
    sp_updatestats updates only the statistics that require updating based on the rowmodctr information in the sys.sysindexes catalog view, thus avoiding unnecessary updates of statistics
    on unchanged rows.
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Maintenance plan for Mirror database

    HI All
    How do we implement Maintenance plan for high safety Database mirroring?
    We have Server A (Principal)and server B (Mirror) and we created maintenance plan on principal server and this maintenance plan have 3 sub plans plan full backup  schedule daily plan 2 log backup every 10 minutes and plan 3 purge the full backup files
    ,log backup files and log history if older then 2 weeks . All jobs are running fine in principal sever .but how to run theses after fail over by agent?
    My client accept maintenance plan,  other wise i will create the jobs with tsql script on both server ,will enable on server where database is principal 
    Please help it very urgent.
    Vanchan

    Hi Vanchan,
    As described in this
    article, when preparing the mirror server to take over the role of principal in the event of a failover, we need to copy maintenance plans from the principal server to the mirror server.
    About how to copy maintenance plans from one Server to other, please follow the steps in the blog below.
    http://mssqltrek.com/2011/08/27/how-to-transfercopy-maintenance-plans-from-one-server-to-other/
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • SharePoint 2010 Database maintenance for beginners / developers

    Hey,
    here is a thing which I concern myself with from time to time.
    As a fulltime developer for SharePoint, I'm not quite familiar with maintaining it's databases. So after I set up my dev environment I usually don't care about maintaining the system. The logical consequence is that the system begins to slow down after a
    while.
    I don't have the time (and - to be honest - not the muse) to deep dive into the recommended maintaing plans by microsoft but I want to keep the performance of my system on an acceptable level. So I read the best practices provided by microsoft about index
    defragmentation, reorganizing, shrinking and so on but for me it's quite difficult to fully dive into these things without spending to much of my business time.
    So I wander if there are any execution-ready T-SQL scripts or something like that, which I can run from time to time to prevent my databases from to high fragmentation. I found some scripts for a stored procedure which reorganizes a particular index. But
    what I am thinking about is a script which iterates through all databases, all tables and all indexes and reorganizes them.
    I'm not looking for the perfect mainenance plan to achieve the best possible performance - I just want to prevent my dev environment from slowing down to much.
    Are there any scripts like that out there? or do you have other tips for me?
    Thank you!

    Hi,
    The steps to configure the maintenance plan is very easy and wont take more than 10 minutes. It is one time activity. It is nothing but drag and drag drop the required tasks from the Tool bar. You can schedule the maintenance plan to run on specific
    time or can run directly on demand basis.
    http://social.technet.microsoft.com/wiki/contents/articles/13956.sharepoint-2010-how-to-create-a-sql-server-2008-r2-maintence-plan-for-sharepoint.aspx 
    If you are looking only for SQL scripts then you may need to post in SQL forum, because maintenance plans will be almost similar for SharePoint Databases/or any SQL DBs.
    Please remember to mark your question as answered &Vote helpful, if this solves/helps your problem. ******************************************************************************************
    Best Regards,
    Pavan Kumar Sapara
    s p kumar

  • Right Steps for Maintenance plan?

    Hi,
    I want to create a maintenance plan in which it has :
    1. Changing recovery models (SIMPLE and then back to FULL)
    2. Reorganizing Indexes
    3. Shrinking the database
    4. Taking a FULL, DIFFERENTIAL & LOG backups.
    So, is this my correct order?? If not then what should be my correct order of the numbers??
    Please advice....
    Regards, Kunjay Shah

    Hi
    I will write you hoe to use T-SQL in order to get what you ask for. This is not a recommendation  to do it! Please read Shanky's
    response.
    1. Changing recovery models (SIMPLE and then back to FULL)
    Done using ALTER DATABASE
    USE master ;
    ALTER DATABASE model SET RECOVERY FULL ;
    http://msdn.microsoft.com/en-us/library/ms189272.aspx
    2. Reorganizing Indexes
    Please read this: http://www.brentozar.com/archive/2013/09/index-maintenance-sql-server-rebuild-reorganize/
    3. Shrinking the database
    http://msdn.microsoft.com/en-us//library/ms190488.aspx
    Please read this befor you start! http://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/
    4. Taking a FULL, DIFFERENTIAL & LOG backups.
    Full: http://msdn.microsoft.com/en-us/library/ms187510.aspx
    Differential Backups: http://technet.microsoft.com/en-us/library/ms175526(v=sql.110).aspx
    Back Up a Transaction Log: http://msdn.microsoft.com/en-us/library/ms179478.aspx
    So, is this my correct order?? If not then what should be my correct order of the numbers??
    * why do you want to change the database backup mode? will you need to return to FULL after the backup? What is the advantage of using FULL if you cut the chain every backup?!? Think if you need a FULL recovery mode if this is your maintenance plan.
    [Personal Site] [Blog] [Facebook]

  • Unable to edit maintenance plan Sql Server 2008R2

    Hi All,
    I am unable to edit sql server maintenance plan and it is failing continuously from job as well.When I try to open the same the throws an error:
    Microsoft SQL Server Management Studio is unable to load this document.:
    Error loading from XML. No further detailed error information can be supplied for this problem because no Event objects was passed where detailed error information can be stored. It used to work pretty well in the past.Throws same error when I try to connect
    remotely.
    Regards
    Rahul

    Has the MP been developed in SQL Server 2008r2 as well?
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Management studio error while creating/editing maintenance plan

    Hi,
    I had MS SQL 2012 enterprise edition installed and everything was working fine. Later I removed MS SQL 2012 and re-installed. Now when I am trying to create maintenance plan I am getting below error. When I click Yes system allows me to go through the maintenance
    plan wizard and create new plan but when I want to edit it give me same error and it doesn't open screen to edit the plans. Can you please provide solution to below error?
    Microsoft SQL Server Management Studio
    The 'Microsoft.DataTransformationServices.VsIntegration.DtsPackage, Microsoft.DataTransformationServices.VsIntegration, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' package did not load correctly.
    The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by running the application together with the /log parameter on the command line, and then examining the file 'C:\Users\pac\AppData\Roaming\Microsoft\AppEnv\10.0\ActivityLog.xml'.Continue
    to show this error message?
    Yes   No   
    I tried repair option from MS SQL 2012 setup but it didn't solve the problem. This is my production system and it has TFS 2013 and it's database. Please let me know how severe this problem is? Is it something to be worried about in future? How do I solve
    this error?
    Regards, Premal Acharya

    Hi Michelle,
    Thanks for your reply. I resolved this issues yesterday by installing SQL Server
    Management Tools Complete. I suspect that
    Microsoft.DataTransformationServices.VsIntegration.DtsPackage, Microsoft.DataTransformationServices.VsIntegration
    DLL files were having issues. When I searched my system I could only find Microsoft.DataTransformationServices.VsIntegration.DLL and
    Microsoft.DataTransformationServices.VsIntegration.DtsPackage.DLL file was missing. 
    When I re-ran the MS SQL setup to add new feature I selected Management Tools Complete and after installation this error was resolved. Though this has solved the issue for now I feel the error shouldn't have come with Management Tools -
    Basic installation as I had installed MS SQL Server before with Management Tools - Basic and it had worked without any issues. 
    For now this issue is resolved but it will be of good help if I can know the cause of this error and what could be the possible solution. 
    Thanks.
    Regards, Premal Acharya

  • Backup Maintenance Plan on SQL AlwaysOn Availability Group Secondary Read-Only node

    I have 3 node SQL 2012 AlwaysOn Availability nodes with the 3rd node as Read-Only.
    The backup job within SQL Maintenance plan is failing with the following error:
    Failed:(-1073548784) Executing the query "declare @backupSetId as int
    select @backupSetId =..." failed with the following error: "Cannot open backup device 'C:\\SQLDBName_backup_2014_06_08_170156_9292095.bak'. Operating system error 2(The system cannot find the file specified.).
    VERIFY DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    I have verified the SQL AlwaysOn Backup preference to be "Prefer Secondary"
    Is there any special steps/settings I need to do to setup and run the backups using maintenance plan in SQL AlwaysOn?

    Hi,
    I'm marking the reply as answer as there has been no update for a couple of days.
    If you come back to find it doesn't work for you, please reply to us and unmark the answer.
    Thanks.
    Tracy Cai
    TechNet Community Support

Maybe you are looking for