WooCommerce server optimization comes down to two compounding problems: a database that quietly fills up with orphaned data over time, and a server that runs out of PHP workers the moment real checkout traffic arrives. Either one alone slows a store down — together, they’re usually why a WooCommerce site that felt fine at launch starts dragging a year and thousands of orders later.
Kinsta gives checkout enough PHP workers to not choke
Database cleanup only solves half the problem — the other half is whether your server has enough PHP workers to handle several checkouts happening at once without queuing. Kinsta runs every site in an isolated container with dedicated resources, so a traffic spike on checkout doesn’t compete with anything else for server capacity.
You still need to do the database cleanup below regardless of host — but on shared hosting, worker exhaustion during a sale is a hosting-architecture problem no amount of query optimization fixes on its own.
We may earn a commission at no extra cost to you.
A store that’s processed a few thousand orders accumulates a real amount of database weight nobody planned for: orphaned postmeta rows left behind by deleted products, expired transients that never got cleared, and post revisions piling up on every product page edit. None of this shows up as a single obvious problem — it shows up as every query running a little slower than it used to.
- Orphaned postmeta rows accumulate whenever a product or order is deleted without its related meta being cleaned up.
- Expired transients often don’t get purged automatically and just sit in
wp_optionsindefinitely. - Post revisions multiply fast on frequently-edited product pages, bloating
wp_postsandwp_postmetatogether.
A slow query doesn’t announce itself — it just makes every page on the store a little heavier, a little at a time.
These queries remove the most common sources of bloat. They’re standard, widely-used cleanup operations — the same kind that plugins like WP-Optimize run automatically — but they modify your database directly, so treat them with the same caution you’d give any direct database change.
Run a full database backup before executing any of the queries below — through your host’s backup tool or a plugin like UpdraftPlus. These are DELETE statements with no undo. If you’re not comfortable running raw SQL, a reputable cleanup plugin does the same job with a safety net built in.
-- Remove orphaned postmeta rows DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL; -- Remove expired transients DELETE FROM wp_options WHERE option_name LIKE '%_transient_%' AND option_name NOT LIKE '%_transient_timeout_%'; -- Remove post revisions DELETE FROM wp_posts WHERE post_type = 'revision'; -- Rebuild table indexes after cleanup OPTIMIZE TABLE wp_posts; OPTIMIZE TABLE wp_postmeta; OPTIMIZE TABLE wp_options;
Even a perfectly optimized database can’t fix a server that runs out of PHP workers. Every checkout request occupies a worker for its full duration — if ten customers check out within the same few seconds and the server only has a handful of workers available, the rest queue up and time out, regardless of how fast the database itself responds.
- Shared hosting typically allocates a fixed, small number of PHP workers shared across every site on the server.
- A sale or promotion that concentrates traffic into a short window is exactly when worker exhaustion happens.
- Isolated hosting architecture gives each site its own worker pool, so one site’s traffic spike doesn’t starve another.
| Symptom | Cause | Fix |
|---|---|---|
| Slow admin, slow product pages | Database bloat | Cleanup queries above |
| Checkout fails under load | PHP worker exhaustion | Isolated hosting resources |
| Both at once during a sale | Compounding effect | Address both together |
Swipe to see full comparison →
Final Take
Database cleanup and hosting architecture solve two different problems, and a fast WooCommerce store needs both. Run the cleanup queries above regularly with a backup in hand, and pair that with hosting like Kinsta that gives checkout dedicated resources instead of a shared, limited worker pool.