When maintaining the ConfigMgr 2007 site database, it is vital to back up the database. An effective backup strategy is crucial to
providing a functional database environment for ConfigMgr; however
additional tasks also need to occur to maintain your ConfigMgr database
effectively.
Tip: Why Do a Separate Database Backup?
Are
there situations where an administrator would want to do a separate
database backup if the site maintenance task is handling the backup? A
common reason for performing a separate database backup is that by
default the maintenance task overwrites the previous backup file. There
are ways to deal with this situation by adding the after-backup.bat file
to specify which commands should be run after a backup (such as moving
the backup file so that it would not be overwritten and stored for
longer periods of time), but a simpler solution might be to perform a
separate database backup.
Database maintenance is
performed using two tasks defined during site installation. These tasks
are available in the ConfigMgr console, at Site Database -> Site
Management -> <Site Code> <Site Name>
Site Settings -> Site Maintenance -> Tasks. The two tasks of note
for database maintenance are the Monitor Keys and Rebuild Indexes
tasks:
Monitor Keys—
This task is enabled by default and runs on Sunday mornings between
12:00 AM and 5:00 AM. ConfigMgr works like other database applications
in that it uses primary keys to identify unique records in a table
quickly. A primary key is a column (or multiple columns) that uniquely
identifies one row from any other row in a database. The ConfigMgr
Monitor Keys task monitors the integrity of these keys within the
ConfigMgr database. As ConfigMgr runs this task itself, the
responsibility of the ConfigMgr administrator is to audit this task is
occurring and completing successfully when it executes.
Rebuild Indexes—
By default, the task is enabled. This task runs every Sunday between
12:00 AM and 5:00 AM. ConfigMgr, similar to other database applications,
uses indexes to speed up data retrieval. As the data in the ConfigMgr
database constantly changes, this task improves performance by creating
indexes on database columns that are at least 50% unique. The task also
drops indexes on columns that are less than 50% unique and rebuilds all
the existing indexes to maximize the performance when accessing these
columns.
Tip: Running Rebuild Indexes with a Large Amount of Database Data
If your ConfigMgr
site database holds a large amount of data, the Rebuild Indexes task can
take a considerable amount of time to run. This task is different from
most tasks in that running it more frequently does not guarantee a
shorter execution time but ensures your ConfigMgr site uses the database
in the most efficient manner.
If there are additional
database maintenance tasks required beyond the Monitor Keys and Rebuild
Indexes tasks, you can add them through the SQL Commands section of the
ConfigMgr console (at Site Database -> Site Management -> <Site Code> <Site Name> Site Settings -> Site Maintenance -> SQL Commands). To add new SQL commands to run custom
maintenance tasks against the ConfigMgr 2007 site database, right-click
on SQL Commands in the console and choose New SQL Commands. The New SQL
Command screen (shown in Figure 1)
provides a dialog box to define the name of the task, the SQL command
to execute, where to log status information to, and a section to
schedule when the maintenance task would occur.
You can use custom SQL
commands to run a SQL command (up to 255 characters) or execute an
existing stored procedure. There are several SQL commands available that
provide maintenance functionality. Some examples of the types of SQL
maintenance you can run include the following:
DBCC CHECKDB (Database Consistency Check)—
This is a stored procedure that checks the logical and physical
integrity of all objects in the site database. Here are some of the
tasks the DBCC CHECKDB stored procedure performs:
- Executing a DBCC CHECKALLOC on the database
- Performing DBCC CHECKTABLE on every table and view in the database
- Executing a DBCC CHECKCATALOG on the database
- Validating the contents of every indexed view in the database
- Validating the Service Broker data in the database
sp_monitor— This system procedure displays SQL Server activities and statistics.
sp_spaceused—
This command displays the number of rows, disk space reserved, and disk
space used by a table in the current database. It also displays the
disk space reserved and used by the entire database.
sp_who— This system procedure determines the number of SQL Server connections currently in use by ConfigMgr 2007 and other processes.
xp_sqlmaint— This command runs database maintenance tasks.
Properly
maintaining your ConfigMgr database environment can go a long way
toward maintaining the functionality and performance of your ConfigMgr
environment.