Search the VMware Knowledge Base (KB)
View by Article ID

Purging old data from the database used by VirtualCenter 2.x (1000125)

  • 109 Ratings


VirtualCenter stores tasks, event, and performance data in the VirtualCenter database. Over time, data collection results in growth of the database files and a mechanism is needed to shrink these files.
VirtualCenter 2.x does not have a feature to purge or shrink old records from the database. For more information on shrinking databases after running the scripts provided in this article, see:
There are two variations of this solution, one for each of the supported vCenter database platforms, Oracle and Microsoft SQL Server. The Oracle version of the scripts are not combined. When you extract the scripts, run the version of the script for the version of VirtualCenter that is in use.
The attached scripts support purging the data from VirtualCenter 2.0 and VirtualCenter 2.5. 
Note: Do not run the scripts attached to this article against a vCenter Server 4.x or 5.0 database. For information about purging data in vCenter Server 4.x or 5.0, see Purging old data from the database used by vCenter Server (1025914).


Caution: The scripts attached to this article are intended for execution by database administrators (DBAs) who are experienced with using database client tools to execute SQL commands. The purpose of the scripts is to delete data. VMware strongly recommends that you stop the VirtualCenter Server service and make a full, reliable backup of your database before attempting this process.

These scripts delete rows, in batches, from designated tables in the VirtualCenter database. However, by default it only reports how many rows are deleted. To actually delete data, a configuration parameter within the script must be modified. This is a safety precaution. Please see the comments in the heading of the script for details. Diagnostic messages are printed that summarize the operations.
The database transaction log may fill up during this procedure if sufficient disk space is not available. For SQL Server, if the required disk space cannot be made available, one option is to utilize the “simple” recovery model on the database for the duration of this operation.
Warning: The VirtualCenter Server service must be stopped while the script is running. For more information, see Stopping, starting, or restarting vCenter services (1003895).
The SQL Server solution consists of one SQL script that can delete tasks, events, and performance data. Simply comment or delete the applicable section of the script if any of these items are not to be purged.
The Oracle solution consists of three separate SQL scripts, one for purging each type of data. Administrators may decide to use one, two, or all three scripts depending on data purging requirements.

  • If the database is very large it may take a very long time to run this script. Running the script in increments by changing the default cut off days of 180 which represents 6 months. For example, assuming you have one year of data (365 days) you can increase this to a larger value like 330 at first and this will purge approximately only one month of data.  You can then run the script with a cut off date set to 300 to purge another month of data.
  • If the scripts fail to run because a lack of available database space, you may need to truncate your performance data.  If you want to truncate all performance data instead of purging it, see Reducing the size of the VirtualCenter database when the rollup scripts take a long time to run (1007453).
  • The script has a note regarding USER CONFIGURABLE PARAMETERS. By default, the flags in the script are set to 0 as a safety measure. The flags must be changed as required. Especially, @DELETE_DATA must be set to 1 be able to delete rows.

Additional Information

For translated versions of this article, see:


purging-old-data  shrinking-a-database


Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.


  • 109 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)

Please enter the Captcha code before clicking Submit.
  • 109 Ratings