A slow database hurts a WooCommerce store in the places page caching can’t reach: the cart, the checkout, customer accounts and the WordPress dashboard where you manage orders. Those pages are built fresh on every request, so every slow query is felt by a shopper or by your team.
There’s no single magic setting. Speeding up the database comes down to four things: good hosting, object caching, taking load off the database, and setting the database up properly. Here’s how we tackle it.
1. Back up first
Several of these steps change your database directly. Take a full backup and know how to restore it before you start. Here’s how to restore backups on WP Alpha.
2. Start with hosting that supports object caching
Hosting sets the ceiling for everything else. A store that leans heavily on the database needs a server that can run a memory based cache like Redis or Memcached. On a VPS you manage yourself you can install one; on managed hosting it needs to be provided for you. WP Alpha hosting includes Redis object caching.
3. Turn on Redis object caching
An object cache sits in front of the database and answers queries it has already seen without asking the database again. Cart updates, checkout and order management in the dashboard are all query heavy, so they benefit the most. The usual setup is:
- Confirm Redis (or Memcached) is available on your hosting
- Add a cache salt key to
wp-config.phpso cached data can’t mix between sites on the same server - Install and enable the Redis Object Cache plugin
Here’s how to set up Redis object caching on WP Alpha.
4. Run the newest PHP version your store supports
Each major PHP release is typically 10 to 30% faster than the one before, and that flows straight through to database heavy work like the cart and checkout. Test the upgrade on a staging site, then change your PHP version.
5. Use page caching to cut database load
Every cached page is a page that doesn’t touch the database. Building a page from scratch typically takes 1 to 4 seconds, while a cached copy comes back in around 0.2 to 0.5 seconds, and the server does a fraction of the work. Shop, category and product pages can all be cached, which leaves more room for the cart and checkout. See how to set up WordPress caching and our guide to WooCommerce caching plugins.
6. Put Cloudflare in front of the store
Cloudflare takes load off your server even on the free plan. It gives you fast DNS, filters out a lot of junk traffic, and its paid plans add edge caching and a fuller firewall. If you can’t use Cloudflare, at least use a CDN for images, CSS, JavaScript and fonts.
7. Convert MyISAM tables to InnoDB
MyISAM, the old MySQL default, locks an entire table while something is written to it. On a busy store, orders, sessions and cart updates end up waiting in line. InnoDB locks only the row being changed, so many writes can happen at once. Think of a spreadsheet only one person can edit versus a shared Google Sheet.
For most databases the free Servebolt Optimizer plugin handles the conversion and also adds useful database indexes. On a database over 1 GB you may need to run it a couple of times. If your database is several GB, don’t use the plugin and don’t do it during trading hours, as it can tie up the server for a long time. Do it through phpMyAdmin instead, ideally with a developer’s help.
8. Enable High-Performance Order Storage (HPOS)
HPOS moves orders out of the shared WordPress posts tables into their own tables, so order queries stop competing with everything else. Turn it on under WooCommerce > Settings > Advanced > Features.
9. Clear expired transients
Transients are temporary data plugins store in the database with an expiry time. Some never get cleaned up and pile up over the years. Go to WooCommerce > Status > Tools and clear both the WooCommerce transients and the expired transients, or use a plugin like WP-Optimize.
10. Remove plugins you don’t use
Older stores collect plugins that no longer do anything useful but still add queries. Disable or delete anything you’re not using.
11. Find the slow queries with Query Monitor
The free Query Monitor plugin shows slow and duplicate queries, PHP errors, memory use and which plugin or theme is responsible. Browse the store, add to cart, go through checkout and open a few orders in the dashboard, then look for the worst offenders. You can also turn on WordPress debug mode to log errors.
12. Keep every plugin updated
Out of date plugins often have small incompatibilities with the current WordPress or PHP version. Pay particular attention to premium plugins bought through marketplaces like ThemeForest, which sometimes don’t show available updates in the dashboard.
13. Check your logs and block the bots
Server logs can show which URLs are being hammered. On WooCommerce we regularly find SEO crawlers adding and removing cart and wishlist items many times a second, and brute force attacks on the login page have a similar effect. Block these with Cloudflare firewall rules and robots.txt (see our WooCommerce robots.txt guide), and use a security plugin like Wordfence to catch login attacks that get through.
14. Watch MySQL processes live
If the database is still under pressure, see what it’s doing right now. Connect over SSH, start the MySQL client with mysql, then run:
show processlist;
That gives you a one off snapshot. To watch it refresh every 0.1 seconds, similar to top, run this from the command line instead. It adds a tiny amount of load, which isn’t a concern.
watch -n 0.1 "mysql -e 'show processlist'"
Give Your Store a Database That Keeps Up
Slow carts, checkouts and order screens usually trace back to the database, and that’s exactly what WP Alpha hosting is set up to handle. You get Redis object caching, server caching, easy PHP upgrades, phpMyAdmin and SSH access, staging sites and automatic backups ready to go.
Moving from another host? We’ll migrate your site for free.
View WP Alpha Plans →