How to Optimize Your WordPress Database (2026 Guide)

Clean and optimise your WordPress database safely in 2026: revisions, transients, autoloaded options, orphaned tables and object caching.

Server racks in a data center, WordPress database optimization guide

Table of Contents

To optimise a WordPress database, back it up, then remove post revisions, auto-drafts, spam and trashed comments, expired transients and leftover tables from deleted plugins, and clean up autoloaded options. Limit future revisions in wp-config.php and schedule a monthly cleanup. On busy sites, add object caching so the database is asked fewer questions in the first place.

Key takeaways
  • Never optimise a database without a fresh backup.
  • Large autoloaded options slow every single page load, including the dashboard.
  • Revisions are useful, but a few per post is enough.
  • Deleted plugins often leave tables and options behind.
  • A clean database helps, but hosting and caching usually matter more for speed.

Why does a WordPress database get slow?

Think of a news blog that has published every weekday for six years. Each article was saved 40 times while editing, a dozen plugins were tried and deleted, and spam comments piled up in the thousands. The database is now several times larger than the actual content, and the dashboard takes seconds to open.

WordPress stores posts, pages, settings, users, comments, WooCommerce orders and plugin data in MySQL or MariaDB tables. Over time it collects clutter that the site never uses but still has to work around.

What can you safely clean from the WordPress database?

ItemSafe to remove?Note
Old post revisionsYesKeep a few recent ones per post
Auto-drafts and trashed postsYesCheck the trash first in case something is needed
Spam and trashed commentsYesAkismet or a similar filter keeps new spam down
Expired transientsYesTemporary cache data that should have been deleted
Orphaned post metaUsuallyMeta rows whose post no longer exists
Tables from deleted pluginsCarefullyConfirm the table prefix belongs to a plugin you removed
Large autoloaded optionsReview firstSet to not autoload or delete only if the plugin is gone

How do you optimise the database step by step?

  1. Back up. Export the database from phpMyAdmin or your host’s backup tool and keep it safe.
  2. Install a cleanup plugin such as WP-Optimize, or use the database tools built into WP Rocket or LiteSpeed Cache.
  3. Clean revisions, drafts, spam and transients. These are the safe, quick wins.
  4. Check autoloaded options. Site Health in WordPress flags when autoloaded options are too large. Find big rows left by old plugins.
  5. Remove orphaned tables only when you are sure which plugin created them.
  6. Optimise tables to reclaim space after large deletions.
  7. Limit revisions by adding define('WP_POST_REVISIONS', 5); to wp-config.php.
  8. Schedule a monthly cleanup so the clutter never builds up again.
Speed optimisationWant a faster site without breaking anything?

Core Web Vitals fixes, caching, image and database tuning on a staging copy first. Free speed check and a fixed quote.

Get a speed quote

What else makes database queries faster?

  • Object caching with Redis or Memcached keeps the results of common queries in memory. It is the biggest win for WooCommerce and membership sites.
  • Find slow queries with Query Monitor. One badly written plugin can run hundreds of queries per page.
  • Use a modern database engine. InnoDB tables and an up-to-date MySQL or MariaDB version handle load much better.
  • WooCommerce: enable High-Performance Order Storage on stores that support it, so orders live in dedicated tables.
Do not run direct SQL DELETE queries copied from forums on a live site. One wrong table prefix can wipe out real content.

A clean database is one piece of a fast site. The full picture is in how to speed up your WordPress website.

Frequently asked questions

Is it safe to optimise the WordPress database?

Yes, if you take a backup first and stick to safe items such as revisions, spam, drafts and expired transients.

How often should I clean the WordPress database?

Monthly for active sites, and after removing plugins or importing large amounts of content.

Will database optimisation speed up my site?

It helps, especially the dashboard and uncached pages. Hosting, caching and images usually have a bigger effect on front-end speed.

What are autoloaded options?

Settings WordPress loads on every page. If old plugins leave large autoloaded data behind, every request becomes slower.

Should I delete all post revisions?

You can, but keeping a few recent revisions per post is a safer balance between recovery and database size.

Sources

Speed optimisationWant a faster site without breaking anything?

Core Web Vitals fixes, caching, image and database tuning on a staging copy first. Free speed check and a fixed quote.

Get a speed quote
Written by Tanvir H

WordPress and Elementor web designer at Tanvir WebXprt, Bangladesh, with 7+ years of experience and 650+ projects for clients worldwide. Tanvir builds, fixes and speeds up WordPress sites every week and writes these guides from that hands-on work.

Keep learning

More WordPress guides

Done for you

Rather have an expert run your WordPress site?

Tanvir H is a Bangladesh-based WordPress and Elementor web designer with 7+ years of experience, 650+ projects and a 4.9 client rating. New websites, redesigns, fixes, speed, security and SEO, handled by one expert who explains everything in plain English and works with clients worldwide.

Website developmentWordPress, Elementor & WooCommerce sitesfrom $899
Fixes & speedErrors, hacks, Core Web Vitals, upgradesFree quote
SEO & paid adsRank on Google, run Meta & Google Adsfrom $300
Creative designWeb, graphic & brand identityfrom $220

Contents

Was this helpful? Spread the word and share with your network!
Facebook
Pinterest
LinkedIn
Reddit
VK
X
Telegram
Threads
Tumblr
Email
WhatsApp
Pocket

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Article