- Behind most slow WordPress sites is a bloated, unoptimized database nobody has ever cleaned.
- Here is how to fix that safely on ordinary shared hosting.
Website owners spend most of their optimization effort on images and caching, while the database — where every post, comment, setting and revision lives — quietly accumulates years of clutter that slows every single page load.
What Bloats a Database Over Time
- Post revisions: WordPress saves a full revision every time a draft is saved, often accumulating dozens per post.
- Spam and unapproved comments: left sitting indefinitely in many installations.
- Transients: temporary cached data that plugins create and frequently fail to clean up after expiry.
- Orphaned data: leftover data from uninstalled plugins that never cleaned up after themselves.
Safe Optimization Steps
- Back up the database first — non-negotiable before any cleanup operation.
- Limit post revisions going forward via a simple wp-config.php setting, preventing future bloat.
- Delete spam and trashed comments in bulk through the WordPress admin.
- Clean expired transients using a reputable cleanup plugin or a direct database query if comfortable with phpMyAdmin.
- Optimize database tables — phpMyAdmin's "Optimize Table" function reclaims space fragmented by deletions.
Using phpMyAdmin Safely on Shared Hosting
Most shared hosting cPanel accounts include phpMyAdmin for direct database access. Always export a full backup before running any manual queries, and test cleanup operations on a staging copy first if your plan supports one.
A Real Before/After Example
A five-year-old WordPress blog with around 400 published posts had never had its database touched since launch. A phpMyAdmin size check showed the wp_posts table alone at over 180MB — the vast majority of it post revisions, since the site had never set a revision limit. After capping revisions to 5 per post going forward and bulk-deleting existing excess revisions and spam comments through a cleanup plugin, the same table dropped to roughly 40MB. Homepage load time, measured with the same PageSpeed Insights test before and after, improved by a meaningful margin — not because the images or CSS changed at all, but because every query touching post data now scanned a table less than a quarter of its previous size.
Advanced: Using WP-CLI for Database Cleanup
For anyone with SSH access, WP-CLI turns several of these manual, click-through tasks into single commands: wp post delete $(wp post list --post_type='revision' --format=ids) --force removes all revisions in one pass, and wp transient delete --expired clears expired transients without needing a plugin at all. WP-CLI is faster and more precise than plugin-based cleanup tools for anyone comfortable with the terminal, and it is worth pairing with our guide to SSH access on shared hosting if this is unfamiliar territory — the same jailed-shell safety that applies to file operations applies here too.
Measuring the Impact
Check your database size before and after cleanup (visible in phpMyAdmin), and measure page load times with a tool like PageSpeed Insights before and after — a heavily bloated database can show meaningful, measurable improvement after a thorough cleanup.
Frequently Asked Questions
How often should database cleanup happen?
Quarterly for an active site is a reasonable rhythm; more frequently for high-traffic sites with heavy comment or e-commerce activity.
Can database cleanup break my website?
Improperly targeted manual deletions can — always back up first and use a reputable cleanup tool rather than freehand queries unless confident in SQL.
Does limiting post revisions lose any content I might want later?
A revision limit only affects future saves; it does not touch your published content, only how many historical draft versions of each post are retained.
Is database optimization worth doing on a brand-new site?
Not urgently, but setting the revision limit from day one is a five-minute preventive step that avoids the entire problem accumulating in the first place.
Need help with a slow, bloated database? See our hosting plans or ask our support team for a performance review.