Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
Search the VMware Knowledge Base (KB)   View by Article ID

Purging old data from the database used by VMware vCenter Server (1025914)


  • VMware VirtualCenter Server service starts, then fails
  • The transaction logs are working correctly
  • You observe excessive growth of the VPX_EVENT table
  • You see this error message in the Microsoft SQL Event log:

    Could not allocate space for object 'dbo.VPX_EVENT'.'VPXI_EVENT_USERNAME' in database 'VCDB' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

  • Viewing the Disk usage by tables report shows the VPX_EVENT and VPX_EVENT_ARG tables utilizing the maximum space.
  • These troubleshooting steps do not help resolve the issue:
    • Purging the old data
    • Truncating tables
    • Shrinking the logs and database
    • Recreating Roll up jobs


VMware vCenter Server stores performance data in the vCenter Server database. Over time, data collection results in growth of the database files and a mechanism is needed to shrink these files. For more information on shrinking databases, see:
VMware vCenter Server has a Database Retention Policy setting that allows you to specify when vCenter Server tasks and events should be deleted. Because this setting does not affect performance data records, it is still possible to purge or shrink old records from the database using the scripts attached to this article.

To access the Database Retention Policy setting in the vSphere Client, click Administration > vCenter Server Settings > Database Retention Policy.

The scripts attached to this article support purging the performance data from vCenter Server.

Caution: Do not run the scripts attached to this article against a VirtualCenter 2.x database.

Note: SQL Express 2005/2008 (vCenter Server 5.x is bundled with SQL Express 2008) supports a maximum of 5 hosts and 50 virtual machines. If your environment exceeds these thresholds, you must upgrade your database to SQL Standard edition.


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 take a full, reliable backup of your database before attempting this process.

These scripts delete rows, in batches, from designated tables in the vCenter Server database. By default, however, it only reports the number of rows that is deleted. To actually delete data, a configuration parameter within the script must be modified. This is a safety precaution. 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).

  • If the database is very large it may take a very long time to run this script. Running the script increments by changing the default cutoff 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 such as 330 at first, and this will purge only about one month of data. You can then run the script with a cutoff date set to 300 to purge another month of data.
  • If the scripts fail to run because of 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 vCenter Server database when the rollup scripts take a long time to run (1007453).
  • If the database has reached a 4 GB limit in SQL Express, the database is corrupted, or if vCenter Server is unavailable for any reason, purge the event and event_arg tables either by manually enabling the database retention policy in the database using SQL Studio, or by running the stored procedure to purge the data from these tables.
  • The vCenter Server database is usually named VIM_VCDB, unless it was renamed during initial creation.
To purge the data in the VPX_EVENT table:
  1. Connect to Servername\SQL Database and log in with the appropriate credentials.
  2. Click databases to expand and select VIM_VCDB > Tables.
  3. Right-click the dbo.VPX_PARAMETER table and select Open.

    : If you are using SQL Server 2008, right-click the dbo.VPX_PARAMETER table and click Edit Top 200 Rows.

  4. Modify event.maxAge to 30, and modify the event.maxAgeEnabled value to true.
  5. Modify task.maxAge to 30, and modify the task.maxAgeEnabled value to true.

    Note: To improve the time of the data cleanup, run the preceding steps in several intervals. To do this, ensure to keep the default value of event.maxAge and task.maxAge and perform step 6 to run the cleanup. Then, reduce the event.maxAge and task.maxAge value by 60 and run the cleanup. Repeat the steps until the value is reached to 30 for the final cleanup process.

  6. Run the built-in stored procedure:

    1. Go to VIM_VCDB > Programmability > Stored Procedures.
    2. Right-click dbo.cleanup_events_tasks_proc and select Execute Stored Procedure.

      This purges the data from the vpx_event, vpx_event_arg, and vpx_task tables based on the date specified for maxAge.

    3. When this has successfully completed, close SQL Management Studio and start the VMware Virtual Center Server service.
To ensure that the default Statistics Level is set to 1:
  1. Using the vSphere Client, log in to vCenter Server as an administrator.
  2. Go to Administration > vCenter Server Settings > Statistics.
  3. Under Statistics Intervals, ensure the Statistics Level column is set to 1.
  4. To change the value, select the Interval Duration, click Edit and select Level 1 from the dropdown.
  • The execution of dbo.cleanup_events_tasks_proc may take a long period of time depending on the database size.
  • The operation may fail due to the transaction logs being filled up at multiple intervals based on the data to be purged. You must shrink the Transaction logs when required and run dbo.cleanup_events_tasks_proc again.

Additional Information

For more information on:

Note: When the vCenter Database has been purged, you may notice an improvement in the performance of the vSphere Client connected to the vCenter Server.

For translated versions of this article, see:
The attached Oracle script works up to vCenter Server 5.0.

Note: The external links present this article were correct as of May 28, 2014. If you find a link is broken, provide feedback and a VMware employee will update the link.

See Also

This Article Replaces


Update History

29/09/2011 - Added VC 5.0 updates 05/06/2011 - Added warning about SQL Express 2005 supportability. 05/20/2013 - Corrected hyperlink for VC 2.x 02/18/2015- Added products VMware vCenter Server 5.1.x and VMware vCenter Server 5.5.x


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.


  • 218 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)
  • 218 Ratings