Opens in a new tab

WordPress Database Optimization: Speed Up a Busy Site

When a WordPress site gets busy, the database is usually the first thing to buckle. Pages that felt instant at launch start to lag, the admin gets sticky, and every…

ForgeHosting
Forge Web Services

When a WordPress site gets busy, the database is usually the first thing to buckle. Pages that felt instant at launch start to lag, the admin gets sticky, and every speed test points at slow server response with no obvious cause. More often than not, a slow WordPress database is behind it. WordPress database optimization is how you fix that: cut the query load, clear out the junk WordPress quietly accumulates, and tune the parts that actually decide how fast a query comes back. This guide walks through it in order, from the five-minute cleanups to the deeper tuning, so a high-traffic site stays fast.

Signs Your Site Needs WordPress Database Optimization

Your database is dragging the site down when the symptoms follow load rather than page weight. The tells:

  • The site slows down as traffic climbs, then recovers when it drops.
  • The WordPress admin is sluggish even though the front end is cached.
  • A query monitoring tool shows a handful of slow queries eating most of the page build time.
  • Server response time is high but your images, scripts, and caching are already sorted.

If that sounds like your site, work through the fixes below top to bottom to reduce database load on a busy WordPress site. They are ordered cheapest-to-fix first, so you get the biggest easy win before touching anything advanced.

Start Here: wp_options Autoload Bloat

This is the single most common hidden database killer, and almost nobody checks it. The wp_options table holds site settings, and every option marked to autoload gets pulled into memory on every single page load, logged in or not, cached or not. A healthy autoload total is a few hundred kilobytes. On a site that has run for years with plugins coming and going, it can balloon into several megabytes of data loaded on every request.

Find out where you stand. Run this in your database tool or WP-CLI:

SELECT ROUND(SUM(LENGTH(option_value))/1024/1024, 2) AS autoload_mb
FROM wp_options WHERE autoload = 'yes';

Anything over about one megabyte is worth investigating. Then list the worst offenders:

SELECT option_name, ROUND(LENGTH(option_value)/1024, 1) AS kb
FROM wp_options WHERE autoload = 'yes'
ORDER BY LENGTH(option_value) DESC LIMIT 20;

You will usually find leftovers from plugins you removed long ago, cached data that a plugin never cleaned up, or a logging option that grew without limit. Delete the rows that belong to plugins you no longer run, and for the ones you do run, switch the option to not autoload if it is not needed on every page. Back up the table first. Trimming autoload from four megabytes to a few hundred kilobytes can shave real time off every request on the site.

Clear Out Post Revisions

WordPress saves a full copy of a post every time you save a draft. On a content-heavy site, a single page can carry dozens of revisions, and the wp_posts table ends up several times larger than the content you actually publish. Bigger tables mean slower queries.

Cap them going forward with one line in wp-config.php:

define('WP_POST_REVISIONS', 5);

That keeps the last five revisions per post and drops the rest as new ones are made. Five is plenty of undo history for most teams. If you would rather clear the backlog now, delete old revisions directly, but back up first and keep the most recent few per post so you do not lose working history.

Purge Expired Transients

Transients are short-lived cached values, and plugins lean on them heavily. The problem is that WordPress does not always clean up expired ones, so wp_options fills with dead transient rows that are past their expiry and never used again. On a busy site with lots of plugins, this pile grows fast.

Clearing expired transients is safe. They are cache by definition, so anything still needed is simply regenerated on the next request. Delete the expired rows, then schedule the cleanup to run on a regular basis rather than doing it by hand. A weekly sweep keeps the table lean without any ongoing effort.

Index the Queries That Hurt

The wp_postmeta table is where most heavy sites bleed speed. WooCommerce, membership plugins, and custom fields all pile metadata into it, and queries that filter on meta_key or meta_value have to scan huge numbers of rows unless there is an index to guide them.

Use a query monitoring tool to find the slow meta queries on your busiest pages, then add a targeted index on the columns those queries filter by. A well-placed index can turn a query that scans hundreds of thousands of rows into one that touches a handful, which is the difference between a checkout page that stalls and one that snaps. Test index changes on staging first and measure before and after, because the wrong index adds write overhead without helping reads.

Tune MySQL So It Stops Hitting the Disk

Everything above trims what the database has to do. Tuning changes how fast it does it. The setting that matters most for WordPress is the InnoDB buffer pool, the chunk of memory the database uses to hold your data and indexes so it can answer from RAM instead of reading the disk. Size it too small and even a clean, well-indexed database crawls, because it is constantly fetching from disk. Size it to comfortably hold your working data set and queries come back from memory.

The catch is that you can only tune MySQL if you can reach its configuration. On most shared hosting you cannot. The database server is set to one-size-fits-all for hundreds of accounts, and buffer pool sizing, query cache behaviour, and connection limits are off the table. This is where do-it-yourself optimization runs out of road, and it is worth knowing that before you spend a weekend on it.

Cache Query Results So the Database Isn’t Hit Twice

The fastest database query is the one you never run. Object caching with Redis holds the results of repeat queries in memory, so when ten visitors trigger the same expensive lookup, the database answers once and the cache serves the other nine. On a busy site, and especially on WooCommerce, persistent object caching takes a large, steady load off the database that no amount of table cleanup can match. Like MySQL tuning, it needs a host that gives you a real object cache rather than a checkbox that does nothing.

The Part You Cannot Clean Up: Shared-Database Neighbours

Here is the ceiling on all of this. You can trim autoload, cap revisions, purge transients, and index every hot query, and on cheap shared hosting your database can still stall, because it is not really your database. On a shared plan your site sits on a MySQL server with hundreds of other accounts, all competing for the same memory and the same query capacity. When a neighbour runs a heavy import or gets a traffic spike, your queries wait in the same line, and your carefully optimized site slows down for reasons that have nothing to do with your site. That is the query lag no cleanup can fix, because the resource was never yours. It is the same noisy-neighbour problem that drives up the real cost of cheap WordPress hosting once you factor in the performance you lose.

That is exactly the layer Forge Web Services removes. Every site runs on its own dedicated VPS, so your database has its own reserved memory and CPU and no stranger’s traffic can crowd your queries. Because the server is yours, the tuning that shared hosting locks away is on the table: we size the InnoDB buffer pool to your data, run persistent Redis object caching per site, and keep server-level caching and a current PHP version in front of it all. Most of the deeper fixes in this guide are already done for you on day one. If you want the full reasoning on why a dedicated server behaves so differently under load, read shared vs dedicated hosting for WordPress, and if you run a store, our guide to WooCommerce hosting for high-traffic sites covers the database pressure a busy checkout puts on the server.

Clean up the database yourself first. It is real work and it pays off. When you have done everything you control and the queries still stall, the database you are renting is the problem. Plans start at $39 per month, every plan includes a free migration, and we move your site with no downtime, so you can watch your own before-and-after. See the plans when you are ready to stop sharing your database with strangers.


Get the pricing spreadsheet and migration checklist.

Start a free migration

Like this kind of writing?

Once a month, in your inbox. No fluff. Just practical WordPress hosting writing you would actually want to read.

Subscribe to the newsletter →

~/blog/related

Forge Web Services

WordPress 7.0 AI Features: What They Actually Need From Your Host

WordPress 7.0, codenamed “Armstrong,” is the biggest core release in years. The headline is that AI is no…

Read post →

Forge Web Services

Best PHP Version for WordPress and WooCommerce in 2026

If you are trying to pick the best PHP version for WordPress in 2026, here is the short…

Read post →

Forge Web Services

WooCommerce HPOS Performance: How to Speed Up Your Store After the 10.8 Update

WooCommerce HPOS changes how orders are stored. Learn what slows your store after the 10.8 update and how…

Read post →