← Back to blog

Database Optimization: Clean Up and Speed Up Your WordPress Database

22/07/2026

$body$

A WordPress database is like a storage room: things get added for years, and almost nothing ever gets thrown out. A three or four year old site often drags around a 500 MB database of which real content makes up 50 MB. The rest is revisions, transients, spam comments and tables from plugins deleted long ago. The bigger and messier the database, the slower the queries — and that shows up directly in TTFB, especially in the admin dashboard and on WooCommerce sites where page caching cannot help.

What actually causes the bloat

  • Post revisions — WordPress keeps every edit forever by default. An article edited 60 times means 60 copies in the database.
  • Expired transients — temporary cache entries plugins write and never delete. Tens of thousands can pile up in wp_options.
  • Spam and trashed comments, along with their meta fields.
  • Tables from deleted plugins — most plugins leave their tables behind on uninstall. Leftovers can carry hundreds of megabytes.
  • Autosaves and drafts nobody will ever open again.
  • WooCommerce sessions and logs that accumulate without limit.

How to clean up safely

Rule number one: backup first. Database cleanup is a one-way operation — deleted means deleted. Then:

  • Install WP-Optimize or Advanced Database Cleaner and just read the report first, delete nothing.
  • Remove revisions older than 30 days, and cap them going forward by adding define('WP_POST_REVISIONS', 5); to wp-config.php.
  • Clear expired transients, spam comments and trash.
  • Only drop orphaned plugin tables once you are 100% sure which plugin owned them — Advanced Database Cleaner shows the owner.
  • Finish by optimizing the tables so the freed space is actually reclaimed.

What speed gains to expect

On neglected sites the results can be dramatic: a database with 40,000 transients in wp_options slows down every single request, because that table loads on every page view. A 100-300 ms lower TTFB and a noticeably faster admin are realistic. On well-kept sites the effect is smaller, but a cleanup every 2-3 months prevents the problem from ever building up.

The role of your host

Database speed also depends on the disk it runs on: on our plans databases run on NVMe storage, which executes queries several times faster than classic SSDs, and daily backups mean you can clean up without fear. If your site is still slow after a cleanup, take a look at our SEO hosting — the bottleneck is often the server, not the database.

$body$
100% GUARANTEE30-day money back

30-day money back

No questions asked. Full refund if you are not satisfied.