Website & Strategy
WordPress Database Cleanup: Speed Up Your Website

Your WordPress site is optimized, your images are compressed, your cache is enabled, and yet your TTFB remains stubbornly high. The cause is often invisible: a database weighed down by years of revisions, orphaned data, and unused tables. If you are working on your Core Web Vitals 2026 and your server response time resists optimization, this is probably where the problem lies.
WordPress automatically records every post revision, every draft, every spam comment, and every entry from an uninstalled plugin. Without regular cleanup, the database grows, SQL queries slow down, and your TTFB soars. Good news: cleanup is simple, fast, and risk-free if you follow a few basic rules.
Why the database slows down your WordPress site
How degradation happens
On every page load, WordPress runs dozens of SQL queries to retrieve content, options, metadata, and widgets. The larger and more fragmented the database is, the slower those queries become. TTFB rises, LCP follows, and your Core Web Vitals score declines.
The main sources of buildup on an active WordPress installation:
Post revisions: WordPress saves a copy every time you save. A post edited 50 times generates 50 revisions stored indefinitely
Autosaves: created continuously while writing, they accumulate without ever being deleted automatically
Spam and trash comments: Akismet and native filters hold back spam without purging it
Orphaned data: metadata left behind by uninstalled plugins, unused postmeta and usermeta
Cluttered wp_options table: expired transient options and accumulated plugin data that are queried on every load
Abandoned tables: some plugins create their own tables and do not remove them upon uninstallation
Measuring the impact
A 3-year-old WordPress site with no cleanup can accumulate tens of thousands of revisions and hundreds of thousands of orphaned rows. On shared hosting, this can mean an additional 200 to 400 ms of TTFB, which can be the difference between an acceptable LCP and a red-zone LCP.
Step 1: Back up before any changes
This is the absolute rule, without exception. Before any database cleanup, perform a complete backup including the files and the database.
Recommended backup tools:
UpdraftPlus: complete backup in one click, storage on Google Drive or Dropbox
Duplicator: ideal for creating a complete copy of the site before intervention
Hosting provider backup: check that your host offers automatic snapshots and enable them
Never trust a single backup. Make sure it is complete and restorable before you begin.
Step 2: Clean with a plugin (recommended method)
For most WordPress sites, a cleanup plugin is enough. It is the safest method because it includes safeguards and requires no SQL knowledge.
WP-Optimize: the reference tool
WP-Optimize is the most complete plugin for this task. It allows you to:
Delete all post revisions in one click
Purge autosaves and trashed posts
Clean spam and trash comments
Delete expired transient data
Optimize and defragment database tables
Recommended settings:
Enable weekly automatic cleanup to keep the database clean over time
Limit future revisions in wp-config.php:
define('WP_POST_REVISIONS', 5);Run table optimization after each cleanup to defragment indexes
Advanced Database Cleaner
A solid alternative to WP-Optimize, particularly effective at detecting and removing orphaned tables left behind by older plugins. Its interface clearly lists each table and its origin, which helps prevent accidental deletions.
Step 3: Clean with phpMyAdmin (advanced method)
For users comfortable with databases, phpMyAdmin offers full control. This method is recommended for sites with very large databases or specific needs.
Access: log in to your hosting account, open cPanel or Plesk, then phpMyAdmin. Select your WordPress site's database.
Essential cleanup SQL queries
Delete all post revisions:
Delete associated orphaned metadata:
Purge expired transient data:
Clean spam comments:
After each cleanup, select all tables and run the "Optimize" operation from the phpMyAdmin dropdown menu. This step defragments indexes and frees up actual disk space.
Step 4: Optimize the wp_options table
The wp_options table is queried on every WordPress page load. It is one of the most critical for TTFB. It accumulates two problematic types of data.
Expired transient data is temporary cache created by plugins. When it expires, it remains in the table until it is manually deleted. An active site can accumulate several thousand of them.
Excessive autoloaded options: WordPress automatically loads into memory all options marked autoload = yes. Some plugins store large amounts of data there that burden every request.
To audit your autoloaded options, run this in phpMyAdmin:
If some large options belong to plugins you no longer use, delete them or disable their autoload.
Step 5: Prevent future buildup
One-off cleanup is not enough. Here are the settings to put in place to keep a database lean over time.
Limit revisions in wp-config.php:
This line limits the number of revisions kept per post to 5. Beyond that, the oldest ones are automatically deleted.
Disable overly frequent autosave:
This spaces autosaves out to every 5 minutes instead of the default 60 seconds.
Schedule automatic cleanup: WP-Optimize lets you schedule an automatic weekly cleanup. Enable this option and pair it with your backup system for a clean, secure cycle.
Audit installed plugins: every active plugin adds SQL queries on each load. Uninstall unused plugins rather than simply disabling them, and check that they properly remove their tables upon uninstallation.
To go further
Database cleanup is one step in a broader performance strategy:
Consult our Core Web Vitals 2026 guide to understand how TTFB fits into the overall set of essential web signals
Discover how to optimize LCP on WordPress to complement your work on server response time
Learn how to set up a Cloudflare CDN to reduce network latency and distribute your resources worldwide
In short
A clean WordPress database is a long-term performance investment. Revisions, drafts, orphaned data, and expired transients quietly accumulate and weigh on every SQL query. Methodical cleanup, combined with preventive settings, can save several hundred milliseconds of TTFB and turn your LCP from red to green. Start with a backup, clean with WP-Optimize, optimize your tables, and schedule a monthly routine. Your database will thank you.
FAQ
How often should you clean the WordPress database? For an active site publishing several posts per week, an automated monthly cleanup is recommended. For a brochure site with few updates, quarterly cleanup is enough. The key is to put preventive settings in place (revision limit, autosave interval) to reduce buildup between cleanups.
Can database cleanup break my WordPress site? The risk is virtually zero if you follow two rules: back up before any changes, and use a dedicated plugin like WP-Optimize rather than manual SQL queries without expertise. Deleting revisions, drafts, and transient data never affects published content or the active features of your site.
Can 3DH Studio optimize my WordPress site's database? Yes. 3DH Studio integrates database auditing and optimization into its technical performance work. We analyze the volume of accumulated data, identify problematic tables, carry out secure cleanup, and put preventive settings in place so your database stays lean in the long term. Result: lower TTFB, improved LCP, and a better Core Web Vitals score.



