Authored by Santos Martinez
Hello, ConfigNinja here to write to you about optimizing the site database in System Center 2012 R2 Configuration Manager. One of the areas we cover with our customers is the ConfigMgr site database. For the past few months I have reviewed data about the site database and ways to improve performance, especially since it’s being used constantly. One of the issues that have come up a few times is fragmented indexes. On this blog post, I will explain how to find out if you have fragmented indexes in the ConfigMgr site database and methods to detect this in your own ConfigMgr site database.
Let’s start by finding out if your site database is fragmented or not. We suggest that you rebuild those indexes if the site database is fragmented more than 10%.
Open SQL Management Studio > and connect to the ConfigMgr SQL Server.
Select New Query >
Select the CM_XXX (your site database)
Execute the following T-SQL command: DBCC Showcontig
Below is sample of the output this command produces:
You can also run the following T-SQL Command Line to identify those tables with more than 10% of Fragmentation:
select distinct sch.name + '.' + OBJECT_NAME(stat.object_id), ind.name, convert(int,stat.avg_fragmentation_in_percent)
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
You can also schedule key maintenance tasks to occur periodically using a SQL Maintenance Plan to optimize database performance. Follow the steps below to create a maintenance plan.
In the SQL Management Studio Console, expand Management > Right Click Maintenance Plan and select Maintenance Plan Wizard.
Provide a name for your maintenance plan and click Next to choose the tasks we want to include in our maintenance plan.
In the Select Maintenance Tasks page, select the following tasks:
Click Next Twice, once you have all the proper tasks selected.
On the next page you will be asked to define the Reorganize Index Task. Click on Databases and select all databases if this SQL Server is used exclusively for ConfigMgr.
Click the schedule option to set the date and time this task should run. Ensure the scheduled frequency is different for each task. Avoid overlaps between tasks.
NOTE: Make there is no overlapping with other maintenance plans or site maintenance tasks, this will include backup or ConfigMgr rebuild index task.
At the Define Rebuild Index Task page, select the same databases as the first screen. It is very important that you match this on every task.
Ensure there is a unique schedule for the job.
Finish up by configuring the Update Statistics Task and ensure it runs after all other tasks have completed.
At the Define History Cleanup Task, select Ok and click Next.
Click Change to schedule the task and click Next
Ensure you clean up your task history and click Next to complete the task.
Maintenance Plan Completed, click close and proceed to the next steps.
Open ConfigMgr Console > go to the Administration Workspace, Expand Sites, select the site and right click Site Maintenance.
Select Rebuild Indexes and click edit.
We disabled the Rebuild Indexes from running on Saturday. The custom maintenance plan will run on that day.
Review the current schedule to ensure no overlap with your new rebuild index maintenance plan.
We need to confirm there is no more fragmentation in our index, you can go back to the first T-SQL command line or follow the next step to confirm your database is back to a healthy state.
again to validate the current fragmentation:
Notice there is no more fragmentation on the tables after the command line. If we test the ConfigMgr console you will notice it should be performing faster than before.
For System Center Configuration Manager 2007:
ConfigMgr Predefined Maintenance Tasks Overview -
Rebuild Indexes Task -
Troubleshooting ConfigMgr Performance - http://technet.microsoft.com/en-us/library/bb932206.aspx
For System Center 2012 Configuration Manager:
Planning for Maintenance Tasks for Configuration Manager -
Santos Martinez – Sr. PFE – ConfigMgr and Databases
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.