Features Pricing Reviews FAQ
Get Plugin

Cleaning and Optimizing Your Database

4 min read

Over time, your WordPress database fills up with data you no longer need. xSpeed Cache can find this extra data, show you how much there is, and remove it when you choose to.

What this does

xSpeed Cache scans your database and counts common types of unneeded data, such as old post revisions and spam comments. It shows you these counts first, so you can see exactly what would be removed before anything is deleted.

When you run a cleanup, xSpeed Cache permanently deletes the data in the categories you select. It can also run OPTIMIZE TABLE to reclaim space in your database tables.

Why use it

A smaller database is quicker to query, which can help your site respond faster. Clearing out spam, trash, and leftover data also keeps your database tidy and easier to manage.

How to clean your database

  1. Open the xSpeed Cache dashboard in /wp-admin/.
  2. Go to the Database panel.
  3. xSpeed Cache runs a scan automatically and shows a count for each cleanup category.
  4. Select the categories you want to clean.
  5. Press the clean button to remove the data in those categories.
  6. The counts refresh so you can see what is left.

Warning: Cleanup permanently deletes data from your database. There is no undo. Back up your database before you run a cleanup, especially the first time.

Cleanup categories explained

xSpeed Cache groups the data it can remove into the following categories. Each one shows a live count of how many items it would clean.

CategoryWhat it removes
Post RevisionsSaved older versions of your posts and pages
Auto-Drafts (older than 7 days)Auto-saved drafts that are more than 7 days old
Trashed PostsPosts and pages currently in the trash
Spam CommentsComments marked as spam
Trashed CommentsComments currently in the trash
Expired TransientsTemporary cached values that have passed their expiry time
Orphan Post MetaPost meta rows whose post no longer exists
Orphan Comment MetaComment meta rows whose comment no longer exists

A few notes on the categories:

  • Post Revisions removes every stored revision. WordPress keeps a copy each time you save a post, and these add up on busy sites.
  • Auto-Drafts (older than 7 days) uses a 7-day grace window on purpose. Drafts you are still working on are left alone, and only auto-drafts older than 7 days are removed.
  • Expired Transients removes only transients that have already expired. Active transients are not touched.
  • Orphan Post Meta and Orphan Comment Meta remove leftover meta rows that point to a post or comment that has already been deleted.

Optimizing tables

Cleaning removes rows, but the space those rows used can stay reserved inside the table. xSpeed Cache includes a separate optimize action that runs OPTIMIZE TABLE on your site’s tables to reclaim that space.

Optimize runs on the tables that use your site’s table prefix. After it finishes, xSpeed Cache reports whether each table was optimized.

Note: Optimizing tables does not delete any content. It reorganizes existing tables so they use space more efficiently.

Best practices

  • Always back up your database before your first cleanup.
  • Start by reviewing the scan counts before you select any category.
  • Run Optimize after a large cleanup so the freed space is reclaimed.
  • If you rely on post revisions for editing history, leave Post Revisions unselected.

Troubleshooting

The count still shows items after I cleaned. Re-run the scan. The counts refresh after each cleanup, so a remaining number means new items have appeared since, or that category was not selected.

A category shows zero. That category has nothing to clean right now. This is normal on a tidy or new site.

FAQ

Can I undo a cleanup? No. Cleanup deletes data permanently. Restore from a database backup if you remove something you needed.

Does cleaning delete my published posts or approved comments? No. The categories only target revisions, drafts older than 7 days, trashed items, spam, expired transients, and orphaned meta. Your live content is not included.

Do I have to clean every category at once? No. You choose which categories to clean. Unselected categories are left untouched.

  • Scheduling Automatic Database Cleanup