Skip to content
Free website migration on every plan, done by our team.Learn more ›
WordPress

How to clean and optimise your WordPress database

Speed up WordPress by cleaning the database: remove old revisions, spam, transients and leftover plugin tables safely, with a backup first.

Short answer: Back up first, then remove old post revisions, spam and trashed comments, expired transients and tables left by deleted plugins. A database optimisation plugin can do most of it safely. Limit future revisions to keep it tidy.

What builds up over time

  • Post revisions: every save keeps a copy.
  • Spam and trashed comments.
  • Expired transients: temporary cached data plugins forget to delete.
  • Orphaned tables and options from plugins you removed.
  • Autoloaded options that load on every page.

A safe clean-up routine

  1. Take a full backup. See WordPress backups.
  2. Use a reputable database clean-up plugin.
  3. Delete revisions, spam, trash and expired transients.
  4. Review leftover tables from deleted plugins before removing them.
  5. Optimise tables.

Prevent bloat

Limit revisions by adding this to wp-config.php:

define('WP_POST_REVISIONS', 5);

When it makes a real difference

Shops and busy sites with years of content see the biggest gains, especially for admin speed and uncached pages. Combine with object caching.

Frequently asked questions

Is it safe to delete revisions?

Yes, after a backup. You lose the ability to restore old versions of posts.

How often should I clean the database?

Every few months for most sites.

Ready when you are

Host it where it performs

NVMe speed, offshore privacy and a written SLA — live in minutes on AuroxHost.