What this problem looks like
Database cleanup is not the same as deleting plugins. Orphan tables from removed plugins and autoloaded options often cause more bloat than post revisions.
Aggressive SQL without understanding breaks WooCommerce orders and page builder data. Prefer targeted tools with dry-run previews.
Step 1: Safe cleanup with WP-CLI on SSH
Only run these commands if you have SSH access to the server.
wp comment delete $(wp comment list --status=spam --format=ids)
wp post delete $(wp post list --post_status=trash --format=ids) --force
wp transient delete --expired
wp cache flush Step 2: Limit post revisions going forward
Open wp-config.php in your site root, next to wp-admin and wp-content. Search for WP_POST_REVISIONS and AUTOSAVE_INTERVAL first. If those lines already exist, update them instead of adding duplicates. If neither exists, paste the constants above the line that says stop editing:
define( 'WP_POST_REVISIONS', 5 );
define( 'AUTOSAVE_INTERVAL', 120 ); Step 3: Plugin-assisted cleanup
WP-Optimize and Advanced Database Cleaner show removable items with checkboxes. Review each category instead of select all blindly.
Step 4: Find autoload bloat on SSH
Only run this command if you have SSH access to the server.
wp db query "SELECT option_name, LENGTH(option_value) AS size FROM wp_options WHERE autoload='yes' ORDER BY size DESC LIMIT 20;" Step 5: After cleanup
- Test checkout, forms, and search.
- Regenerate critical CSS if a performance plugin requests it.
- Schedule quarterly cleanup instead of yearly panic deletes.
When to stop DIY and hire help
Shops with years of order data need surgical cleanup, not generic plugins. BugShield optimizes WordPress databases at a confirmed fixed price with tested restore points.