🚀 New: WordPress Care Plans starting at $49/mo — see plans & pricing →
Fiverr
Upwork
LinkedIn
YouTube
WhatsApp
BD Local Guide
SEO Services
📝
On-Page Optimisation
🔍
Indexing & Crawling
Core Web Vitals
🔗
Backlinks & Off-Page SEO
📍
Local SEO & Map Pack
🛒
E-Commerce SEO
📈
Affiliate Content Scaling
🚨
Traffic Drops & Penalties
WordPress
🔧
WordPress Technical SEO
🛡️
Care Plans — from $49/mo
📦
Products & Tools
Resources
SEO Checklist 2026
💰
SEO Strategy & ROI
🛠️
Tools We Recommend
Company
👋
About Us
👋
Our Portfolio

WordPress SEO that actually ranks

Technical SEO, speed optimisation, and monthly care plans for WordPress sites that need to perform.

How to Clean Up WordPress Database for SEO (Complete Guide) | indxq.com
WordPress SEO

How to Clean Up Your
WordPress Database for SEO

A bloated WordPress database silently slows every page load on your site — increasing TTFB, degrading Core Web Vitals, and dragging down rankings. This guide covers every source of database bloat, how to safely remove it, and how to keep your database lean long-term.

indxq Editorial Team · 26 min read · WordPress SEO Core Web Vitals
🗄️
Always Back Up Before Any Database Operation
Every cleanup step in this guide modifies your database permanently. Run a full database backup — via your host’s control panel, phpMyAdmin export, or a plugin like UpdraftPlus — before touching anything. If your site runs on a slow host and database bloat alone isn’t fixing performance, see our guide on why your WordPress site is slow on mobile for the complete diagnosis.

The connection between WordPress database health and SEO is indirect but measurable. Google’s Core Web Vitals use Time to First Byte (TTFB) as a primary signal for Interaction to Next Paint (INP) and Largest Contentful Paint (LCP) scoring. A bloated WordPress database increases the time your server spends executing queries before it can even begin sending HTML to the browser — directly inflating TTFB and suppressing your Core Web Vitals scores.

On a site with years of content, plugin churn, and no database maintenance, it is common to find databases that are 5–20× larger than necessary. The performance impact is not hypothetical: removing post revisions and transients alone can reduce average query execution time by 30–60% on high-bloat databases — measurable in your server response logs within 24 hours of cleanup.

How Database Bloat Affects SEO and Core Web Vitals

WordPress stores almost everything in its MySQL database — posts, pages, options, user data, comments, metadata, and the accumulated residue of every plugin that has ever been installed. Over time, without active maintenance, the database accumulates rows that are never queried but slow down every lookup that does happen.

✗ Bloated Database
  • TTFB 800ms–2.5s on shared hosting
  • Post revisions: 50–200 rows per published post
  • wp_options table: 10,000–80,000+ rows
  • Expired transients: thousands of stale cache rows
  • Orphaned postmeta from deleted plugins
  • Auto-draft and trashed content accumulating
  • LCP and INP failing Core Web Vitals thresholds
✓ Clean Database
  • TTFB 80–200ms on the same hosting plan
  • Post revisions: limited to 3–5 per post
  • wp_options table: 200–800 rows, all autoloaded relevant data
  • No expired transients — regular scheduled cleanup
  • Metadata tables contain only current plugin data
  • No orphaned drafts, trashed posts, or stale content
  • Core Web Vitals passing at current traffic volumes

The SEO impact compounds beyond raw speed. Google’s crawl budget — the number of pages Googlebot crawls on your domain per day — is partially governed by your server response time. A site with TTFB above 500ms will find Googlebot crawling fewer pages per session and potentially missing freshly published content for days after publication. Reducing TTFB through database optimisation improves crawl efficiency directly.

Related — Performance Best Caching Plugin for WordPress Core Web Vitals — Full Comparison and Setup →

Anatomy of WordPress Database Bloat

WordPress stores data across a set of core tables, each with its own bloat characteristics. Understanding which tables accumulate waste and why helps you prioritise cleanup work and understand what each operation is doing.

wp_posts
Post Revisions & Autosaves
High Impact
Every time you save or autosave a post, WordPress stores a full copy as a revision row. A 500-post site with no revision limit can accumulate 10,000–50,000 revision rows, multiplying table size and query time.
wp_options
Transients & Plugin Options
High Impact
The most commonly bloated table. Plugins store temporary data (transients), settings, and cached values here. Many plugins never clean up after themselves, leaving thousands of stale rows that are autoloaded on every page request.
wp_postmeta
Orphaned Post Metadata
Medium Impact
When posts are deleted, their associated postmeta rows often remain. When plugins are deactivated or replaced, the custom fields they created persist. Over years, postmeta becomes a graveyard of metadata from old plugins and deleted content.
wp_comments
Spam & Unapproved Comments
Medium Impact
Spam comments accumulate rapidly on unprotected sites — thousands of rows that slow comment queries and inflate database size. Trashed and unapproved comments from years past add further bloat without providing any content value.
wp_usermeta
Orphaned User Metadata
Lower Impact
Deleted users and deactivated plugins leave usermeta rows behind. Lower volume than postmeta bloat but still worth addressing in the table optimisation phase.
wp_termmeta
Term & Taxonomy Metadata
Lower Impact
Category, tag, and custom taxonomy metadata left behind by SEO plugins, WooCommerce, or custom taxonomies that were later removed. Low individual row weight but worth cleaning in a full audit.

Diagnosing Your Database Size and Bloat Sources

Before running any cleanup, you need a precise picture of your database’s current state — which tables are largest, how many revision rows exist, and how bloated your wp_options autoloaded data is. This baseline also lets you measure the impact of cleanup afterward.

1
Check Total Database Size in phpMyAdmin
Log into your hosting control panel and open phpMyAdmin. Select your WordPress database. The table list shows each table’s size (“Data” + “Index” columns). Note the total “Size” at the bottom. A well-maintained WordPress site with 500 posts should be under 50MB; sizes above 200MB on sites this size indicate significant bloat.
2
Run a Quick Bloat Audit Query
In phpMyAdmin, open the SQL tab on your database and run the following queries to identify your top bloat sources before cleanup. These give you precise counts of the highest-impact waste categories.
-- Count post revisions (post_type = 'revision')
SELECT COUNT(*) AS revision_count
FROM wp_posts
WHERE post_status = 'inherit'
  AND post_type = 'revision';

-- Count expired transients in wp_options
SELECT COUNT(*) AS expired_transients
FROM wp_options
WHERE option_name LIKE '_transient_%'
   OR option_name LIKE '_site_transient_%';

-- Total autoloaded data size in wp_options (in KB)
SELECT ROUND(SUM(LENGTH(option_value)) / 1024, 2) AS autoload_kb
FROM wp_options
WHERE autoload = 'yes';

-- Count spam and trashed comments
SELECT comment_approved, COUNT(*) AS count
FROM wp_comments
GROUP BY comment_approved;
📊 What the Numbers Mean

Revision count above 5,000: high priority cleanup. Transient count above 500: significant option bloat. Autoloaded data above 800KB: critical — this data loads on every single page request regardless of whether it is needed. Autoload bloat above 1MB will noticeably inflate TTFB on every page.

Cleaning Post Revisions and Autosaves

Post revisions are typically the single largest source of row bloat in the wp_posts table. WordPress saves a revision every time you click “Update” or every 60 seconds via autosave, with no limit by default. On a site with 3 years of regular publishing, it’s common to find 20,000–80,000 revision rows outnumbering actual published posts by a factor of 10 or more.

Step 1: Limit Future Revisions First

Before deleting existing revisions, set a limit so the problem doesn’t immediately recur. Add this line to your wp-config.php file, above the line that reads /* That's all, stop editing! */:

/* Limit post revisions to 5 per post */
define( 'WP_POST_REVISIONS', 5 );

A value of 3–5 is appropriate for most editorial workflows. If you need no revision history at all (e.g., a site managed by a single developer), you can set this to false — but retaining a small number of revisions provides a safety net for accidental content overwrites.

Step 2: Delete Existing Revision Backlog via SQL

1
Delete All Revision Rows from wp_posts
In phpMyAdmin, run this query on your WordPress database. It removes all rows with post_type = 'revision' — both manual save revisions and autosave drafts. Back up first. This is irreversible.
-- Delete all post revisions and autosave drafts
DELETE FROM wp_posts
WHERE post_type = 'revision';

-- Clean up orphaned postmeta left by deleted revisions
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;
⚠️ WooCommerce Sites: Check Before Deleting

WooCommerce stores order data using post_type = 'shop_order' — not revisions — so the revision query above is safe for WooCommerce. However, run a SELECT version of the query first (replace DELETE FROM with SELECT COUNT(*) FROM) to confirm the row count matches your expectation before executing the delete.

Removing Expired Transients and Option Bloat

The wp_options table is the most consequential bloat source for page load performance because WordPress autoloads a significant portion of this table on every single request — before any content rendering begins. Autoloaded data above 800KB noticeably increases TTFB; above 2MB, the performance impact becomes severe on shared and budget hosting.

Clearing Expired Transients

Transients are temporary data stored in wp_options by WordPress core and plugins. They have expiry times, but WordPress only deletes them when they are accessed after expiry — not proactively. A site that stored thousands of transients that were never re-accessed after their expiry accumulates them indefinitely.

-- Delete all expired transients (safe to run)
DELETE FROM wp_options
WHERE option_name LIKE '_transient_%'
   OR option_name LIKE '_site_transient_%';

-- After clearing transients, verify autoload size improved
SELECT ROUND(SUM(LENGTH(option_value)) / 1024, 2) AS autoload_kb
FROM wp_options
WHERE autoload = 'yes';

Identifying Bloated Autoload Rows

After clearing transients, if your autoloaded data is still above 800KB, run this query to identify the specific options contributing the most weight. Large autoloaded rows are typically left by inactive plugins that stored settings or cached data and never cleaned up:

-- Top 20 largest autoloaded options by size
SELECT option_name,
       LENGTH(option_value) AS size_bytes,
       ROUND(LENGTH(option_value) / 1024, 1) AS size_kb
FROM wp_options
WHERE autoload = 'yes'
ORDER BY size_bytes DESC
LIMIT 20;

For each large autoloaded option you identify, research which plugin created it before deleting it. Options from active, essential plugins should not be removed. Options from deactivated or replaced plugins — identifiable by the plugin’s slug in the option_name — can be safely deleted.

⚙️ Plugin Conflicts Yoast SEO Conflicting with Other Plugins — Diagnosing and Resolving the Conflicts →

Clearing Orphaned Data and Spam

Beyond revisions and transients, a thorough database cleanup addresses several other categories of orphaned and stale data that accumulate invisibly over the life of a WordPress site.

Trashed Posts, Pages, and Auto-Drafts

-- Delete trashed posts and pages permanently
DELETE FROM wp_posts
WHERE post_status = 'trash';

-- Delete auto-draft content (unsaved editor sessions)
DELETE FROM wp_posts
WHERE post_status = 'auto-draft';

-- Clean up postmeta for any newly orphaned post IDs
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;

Spam and Trashed Comments

-- Delete spam comments
DELETE FROM wp_comments
WHERE comment_approved = 'spam';

-- Delete trashed comments
DELETE FROM wp_comments
WHERE comment_approved = 'trash';

-- Clean up orphaned commentmeta
DELETE cm FROM wp_commentmeta cm
LEFT JOIN wp_comments c ON cm.comment_id = c.comment_ID
WHERE c.comment_ID IS NULL;
💡 SEO Indexing Note on Comments

If you have categories, tags, or archives set to index, cleaning up spam and low-quality comments also improves the quality of any pages where comment count is displayed and potentially the thin-content profile of low-engagement posts. For related indexing decisions in WordPress, see: WordPress categories indexing issues fix.

Optimising Database Tables

After deleting large volumes of rows, MySQL tables retain the disk space that was occupied by those rows as “overhead” — allocated but empty space within the table file. Running an OPTIMIZE TABLE command reclaims this space, defragments the table, and rebuilds indexes for faster queries. This is the final step of every cleanup cycle.

1
Optimise All WordPress Tables via phpMyAdmin
In phpMyAdmin, select your WordPress database. On the table list page, scroll to the bottom and click “Check all” (the checkbox next to the first table header), then from the “With selected” dropdown choose Optimize table. phpMyAdmin will run OPTIMIZE TABLE on all selected tables sequentially. This temporarily locks each table during optimisation — do this during low-traffic hours.
2
Or Run via SQL for Targeted Tables
If you want to target only the tables most affected by your cleanup, run the OPTIMIZE TABLE command directly. Focus on the tables you deleted rows from: wp_posts, wp_postmeta, wp_options, wp_comments, and wp_commentmeta.
-- Optimise the tables most affected by cleanup
OPTIMIZE TABLE wp_posts;
OPTIMIZE TABLE wp_postmeta;
OPTIMIZE TABLE wp_options;
OPTIMIZE TABLE wp_comments;
OPTIMIZE TABLE wp_commentmeta;

Measuring TTFB Before and After

To quantify the SEO performance improvement from your database cleanup, measure TTFB in Google Search Console’s Core Web Vitals report, PageSpeed Insights, or directly in Chrome DevTools (Network tab → first HTML document request → “Waiting (TTFB)” row). Record your TTFB baseline before cleanup and re-measure 48–72 hours after, allowing server-side caching to warm and measurements to stabilise.

TTFB RangeCore Web Vitals RatingTypical CausePriority
Under 200ms Good Clean database, good hosting, effective caching Maintain
200–500ms Needs Improvement Moderate bloat or inadequate caching layer Address caching first
500ms–1s Poor Significant database bloat, slow hosting, or heavy theme queries Immediate cleanup + caching
Above 1s Critical Severe bloat, shared hosting overload, or unoptimised queries from plugins/theme Cleanup + hosting review
🔧 Next Performance Step How to Fix Render-Blocking Resources in WordPress — JS and CSS Optimisation Guide → 🎨 Theme Performance How to SEO-Optimize a Heavy WordPress Theme — Query Reduction and Asset Cleanup →

Automating Ongoing Database Maintenance

A one-time database cleanup is valuable; a site that never accumulates significant bloat again is better. Automating maintenance prevents the gradual re-accumulation of revisions, transients, and orphaned data between manual cleanups.

Plugin-Based Automation

The most practical approach for most WordPress sites is a maintenance plugin that handles scheduled cleanup without requiring repeated manual SQL work. Three reliable options:

  • WP-Optimize — purpose-built for database cleanup. Schedules revision deletion, transient cleanup, and table optimisation on a daily or weekly basis. Handles cleanup without requiring phpMyAdmin access.
  • Advanced Database Cleaner — more granular control over what is cleaned, with the ability to preview row counts before deleting. Useful if you want to audit before automating.
  • WP-Sweep — lightweight option focused specifically on orphaned data cleanup. Pairs well with a caching plugin that handles transient management separately.
✅ Recommended Maintenance Schedule

Run transient cleanup daily (scheduled automatically by your maintenance plugin). Run revision trimming and table optimisation weekly, during off-peak hours. Run a full phpMyAdmin audit monthly, re-running the diagnostic queries from Section 3 to catch any new sources of bloat from recently installed plugins.

wp-config.php Hardening

Beyond scheduled cleanup, several wp-config.php constants reduce database writes at the source — preventing bloat before it starts:

/* Limit revisions (5 is a sensible default) */
define( 'WP_POST_REVISIONS', 5 );

/* Increase autosave interval to reduce revision frequency */
/* Default is 60 seconds; 300 seconds is reasonable */
define( 'AUTOSAVE_INTERVAL', 300 );

/* Empty trash automatically after 7 days */
define( 'EMPTY_TRASH_DAYS', 7 );
🔍 SEO Plugin Impact on Database Rank Math vs. Yoast — Which Is Better for Traffic and Which Creates Less Database Bloat → 📄 Related — Post Type SEO WordPress Custom Post Types Not Ranking — Database Schema and SEO Configuration Fixes → 📑 Related — Archive SEO WordPress Pagination SEO Best Practices — rel=next, canonical, and Query Performance →
// Database Cleanup Principle

A WordPress database cleanup is not a one-time event — it’s a maintenance discipline. The SEO return on a clean, optimised database is measurable in TTFB, crawl efficiency, and Core Web Vitals scores. Back up first, measure before and after, then automate what you’ve done manually so you never have to do it at this scale again.

More WordPress SEO Guides

This guide is part of indxq’s complete WordPress SEO series — covering performance, plugins, indexing, and technical configuration:

IQ

Sayed Iftekharul Haque — SEO Strategist & Web Designer

Founder of IndXQ. Specialises in SEO-first website redesigns, Core Web Vitals, and digital growth strategy. Available for projects via Fiverr, Upwork, and direct engagements. Connect on LinkedIn or watch free SEO tutorials on YouTube.

Published by IndXQ · Web Strategy & SEO · April 2026 · All rights reserved.

Scroll to Top