Back to Guides
Database 10 min Updated 2026

Deep Database Cleanup & Tuning

Remove bloat, optimize tables, and keep your WordPress database lean for faster query execution.

Deep Database Cleanup & Tuning for WordPress 2026

Your WordPress database is the brain of your website. Over time, it gets clogged with "brain fog"—post revisions, spam comments, transient options, and orphaned metadata. This bloat slows down queries and increases Time to First Byte (TTFB).

In this guide, we will perform a deep clean of your database to restore peak performance.

Why Database Optimization Matters

Every time a user visits a page, WordPress queries the database to find the title, content, author, settings, and more.

  • Bloated Database: WordPress has to search through thousands of useless rows to find the data it needs.
  • Optimized Database: Queries are instant, and pages load faster.

Step 1: Backup Your Database

STOP. Do not proceed without a backup. Database operations are irreversible.

  1. Use a plugin like UpdraftPlus.
  2. Or use your hosting panel (cPanel/phpMyAdmin) to Export the database.

Step 2: Cleaning Up with WP-Optimize

The easiest way to clean the database is using a dedicated plugin. We recommend WP-Optimize or Advanced Database Cleaner.

Configuration

  1. Install and activate WP-Optimize.
  2. Go to WP-Optimize > Database.
  3. Select the following items to clean:
    • Clean all post revisions: WordPress saves a copy every time you hit save. You likely don't need 50 versions of one post.
    • Clean all auto-drafts: Useless drafts created when you clicked "New Post" but didn't write anything.
    • Clean all trashed posts: Permanently remove items in the trash.
    • Remove spam and trashed comments: Get rid of the junk.
    • Remove expired transient options: Temporary data that is no longer needed.
  4. Click Run all selected optimizations.

Step 3: Limiting Post Revisions

To prevent the database from getting bloated again, limit the number of revisions WordPress keeps.

Add this line to your wp-config.php file (above the "That's all, stop editing" line):

[object Object],( ,[object Object],, ,[object Object], );

This tells WordPress to keep only the last 5 revisions of each post.


Step 4: Cleaning up Autoloaded Data

"Autoloaded" data is loaded on every single page load. If plugins leave behind large settings arrays here, it can kill your site speed.

  1. In WP-Optimize, go to the Tables tab.
  2. Look for the wp_options table.
  3. Check the Data Size and Index Size.
  4. If it's huge (over 5-10MB), you might have an issue.

To fix this manually (Advanced):

  1. Open phpMyAdmin.
  2. Run this query to find the biggest autoloaded options:
    [object Object], option_name, length(option_value) ,[object Object], option_value_length ,[object Object], wp_options ,[object Object], autoload ,[object Object], ,[object Object], ,[object Object], ,[object Object], option_value_length ,[object Object], LIMIT ,[object Object],;
  3. If you see options from plugins you deleted years ago, delete those rows.

Step 5: Optimizing Database Tables

Over time, database tables can become fragmented (like a hard drive). Optimizing them re-organizes the data storage for efficiency.

  1. In WP-Optimize, check all tables.
  2. Click Optimize.

Conclusion

A clean database is a fast database. By removing thousands of unnecessary rows, you ensure that WordPress can find what it needs instantly.

In the next guide, we will look at Minification, shrinking your code files to make them download faster.