Skip to content

KeNIC-accredited .KE registrar

Development · Technical

Database optimisation for high-traffic WordPress sites

Why WordPress databases slow down under load, and five ways to keep them fast: page and object caching, clean-ups, finding slow queries, current software and WooCommerce tips.

By John KariukiPublished Updated 6 min read

Eyeglasses reflecting computer code on a monitor

The short answer

  • Page caching keeps most visits away from the database.
  • WordPress’s object cache isn’t persistent by default; add Redis or Memcached for busy and logged-in sites.
  • Clean up revisions, transients, spam and bloated autoloaded options regularly.
  • Use current PHP and MySQL/MariaDB, and find slow queries before traffic peaks.

When a WordPress site gets busy (a news portal during breaking news, an online store on Black Friday, or a membership site with many logged-in users), the database is often the first thing to slow down. Every uncached page can trigger dozens of database queries. Here’s how to keep the database fast as traffic grows.

Why databases slow down

  • Too many queries per page from plugins, page builders and complex themes.
  • Bloated tables: post revisions, spam comments, expired transients, logs and abandoned carts.
  • Large “autoloaded” options loaded on every page.
  • Slow, unindexed queries from custom code or plugins.
  • Outdated database software or too little server memory.

1. Cache as much as possible

Page caching serves ready-made HTML so most visits never touch the database. For logged-in users, carts and dynamic pages, add object caching. WordPress’s object cache is non-persistent by default, meaning it only lasts for one request; a persistent object cache such as Redis or Memcached keeps query results between requests. Since WordPress 6.1, the Site Health screen checks for page caching and recommends a persistent object cache when it would help.

2. Clean up the database

  • Limit post revisions and delete old ones.
  • Remove spam and trashed comments.
  • Clear expired transients.
  • Trim log tables created by plugins.
  • Review large autoloaded options left by removed plugins.

Always take a backup first (see backups).

Close-up of server racks in a data centre
Caching keeps most visits away from the database entirely.

3. Find slow queries

Use a query monitoring plugin on a staging site, or your host’s slow query log, to find the plugins or pages causing heavy queries. Replace or fix the worst offenders, and add database indexes for custom queries where needed.

4. Keep software and server current

WordPress recommends PHP 8.3 or greater and MySQL 8.0+ or MariaDB 10.11+. Make sure the server has enough memory for the database, and consider a VPS or dedicated database resources for very busy sites (see how much hosting you need).

5. WooCommerce and large catalogues

Use WooCommerce’s High-Performance Order Storage where available, archive old orders, and keep product filters efficient. Test checkout under load before big sales (see preparing for Black Friday).

Checklist for high-traffic sites

  • Full-page caching and a CDN.
  • Persistent object cache (Redis or Memcached).
  • Regular database clean-ups.
  • Current PHP and MySQL/MariaDB.
  • Monitoring for slow queries and server load.

Need help with a busy site? See news portal strategies or our web development services.

Frequently asked questions

What is a persistent object cache?

A cache, such as Redis or Memcached, that stores database query results between requests, reducing database load.

How do I clean up a WordPress database?

Back up first, then remove old revisions, spam, expired transients and plugin leftovers, using a trusted plugin or carefully in phpMyAdmin.

Why is my WordPress admin slow?

Often heavy plugins, large autoloaded options or slow queries; caching doesn’t help logged-in admin pages as much.

Which database version does WordPress recommend?

MySQL 8.0 or greater, or MariaDB 10.11 or greater.

Sources

Facts checked on 4 November 2026. Prices and rules change; confirm current details with the provider or regulator.

About the author. John Kariuki is the founder of Kenya Website Designers in Nairobi. He builds business websites, online stores with M-Pesa payments and custom web systems, and manages domains and hosting for Kenyan businesses.

Free quote

Handle more traffic

Tell us about your site and traffic. We reply within 24 hours.