A bloated WooCommerce database causes slow admin pages, sluggish order processing, and oversized backups. Regular cleanup keeps your store running efficiently. Here is what to clean and how to do it safely.
What Accumulates in a WooCommerce Database
- Expired transients — temporary cache data that never got cleared
- Post revisions — every time you save a product or page, WordPress creates a revision
- Old sessions — visitor session data older than 48 hours
- Orphaned order items — order line items with no parent order
- Old logs — WooCommerce error and activity logs
- Unused product metadata — leftover data from uninstalled plugins
Step 1: Enable HPOS First
Before running cleanup, enable WooCommerce → Settings → Advanced → Features → High-Performance Order Storage. HPOS moves orders to dedicated optimised tables, significantly improving order query performance. This is the single highest-impact database performance change for most WooCommerce stores.
Step 2: Clean with WP-Optimize
Install WP-Optimize (free). Go to WP-Optimize → Database. Run in this order:
- Clean Post Revisions — removes old drafts (keep last 3-5 if you want undo ability)
- Clean Expired Transients — safe to delete all expired ones
- Clean WooCommerce Sessions — remove sessions older than 48 hours
- Clean Orphaned Post Meta — removes metadata from deleted posts
Do not run all at once on first use — go step by step and verify the site works after each.
Prefer to have someone handle the setup? Describe what you need and get a free estimate — no obligation.
Step 3: Limit Future Revisions
Add to your wp-config.php to limit revision storage going forward:
define('WP_POST_REVISIONS', 5);
This keeps only the 5 most recent revisions per post, preventing unlimited revision accumulation.
Step 4: Schedule Automatic Cleanup
In WP-Optimize → Settings, enable scheduled cleanup (weekly for most stores, daily for high-volume stores). Schedule it during off-peak hours. Automated cleanup prevents the database from re-bloating after your manual cleanup effort.
Measuring the Before and After
Before running cleanup, record your baseline metrics so you can measure the improvement:
- Open WooCommerce → Orders and note how long the page takes to load
- Run a database size check in phpMyAdmin or your hosting control panel
- Check the wp_posts and wp_postmeta table sizes specifically — these are usually the largest in WooCommerce databases
After cleanup, compare. A database that previously took 8 seconds to load the orders page often loads in 2-3 seconds after clearing revisions, sessions, and transients. The difference is most visible in the WordPress admin, not on the customer-facing frontend (which is typically cached).
When to Involve Your Host
For very large WooCommerce databases (10GB+), plugin-based cleanup may time out before completing. In this case:
- Contact your host and ask them to run the cleanup via direct MySQL — most managed hosts will do this as a support task
- Use WP-CLI directly on the server if you have SSH access:
wp transient delete --expiredclears expired transients without PHP timeout constraints - Consider a database management service or a developer with direct server access for databases at this scale