Optimize WordPress Database Easily in 5 Minutes



WordPress uses MySQL database for storing your plugin settings, post content, theme data, etc stuff. Over the time, it can go bloated with orphan tables and unused data. Using some technique you can keep your Database optimized.

Tip 1. Limit Post Revision
Whenever you update your blog post, WordPress creates revision files so you can restore it from the back date. However, it can increase database size massively suppose if you have written a post, for example, Daily Deals, that you update regularly. Chances are it revisions can bloat your database heavily.

So, in this case, using below trick would be helpful. Where to place? In the wp-config.php file, just before That’s all, happy Blogging comment line.

define( 'WP_POST_REVISIONS', 3);

Or, If you don’t care revision, you may simply turn it off.
define( 'WP_POST_REVISIONS', false);

Tip 2. Change Auto Save Post Interval
WordPress has habit to save automatically new post while editing, every 60 seconds. You can manage time duration by adding this code in your wp-config.php file. Source: Codex.

define( 'AUTOSAVE_INTERVAL', 120 );

Tip 3. Use a plugin to clean up junks of Database

A plugin - WP Sweep can help you in optimizing database in few clicks. This plugin cleans up following things -

  • Revisions
  • Auto drafts
  • Deleted comments
  • Unapproved comments
  • Spammed comments
  • Deleted comments
  • Orphaned post meta
  • Orphaned comment meta
  • Orphaned user meta
  • Orphaned term meta
  • Orphan term relationships
  • Unused terms
  • Duplicated post meta
  • Duplicated comment meta
  • Duplicated user meta
  • Duplicated term meta
  • Transient options
  • Optimizes database tables
  • oEmbed caches in post meta

Warning: WP-Sweep is not compatible with Meta Slider plugin. If you use it, try alternative plugin called WP Optimize.

How to use WP Sweep in WordPress?

  1. Install & Activate WP Sweep Plugin in WordPress

  2. Go to Plugin UI: Tools > WP Sweep

  3. Here, everything you can sweep at once.

    However, I would not recommend following this shortcut which may hurt you back.

  4. Instead, please keep patience and consider choosing to Sweep one by one that makes sense for your blog as per requirements. The good thing about this plugin is you can also see what exactly it is going to clean up. If you don’t understand anything, please click on Details, search related table name on Google or ask below in reply section.

  5. By clicking on Sweep button next to each details, you are going to clean up the Junk data.

Bonus tips

  1. If you are running a busy WordPress site with below Redirection plugin, Beware of logs!
    Keep below settings to avoid bloating database.

  2. If you uninstall WordFence plugin, make sure to select Delete Wordfence tables and data on deactivation before going to delete the plugin.

    I hope this helps.


Thanks & Regards,

How to Resolve High CPU Usage?
Speed Up WordPress (Top 5 High Priority Tips)
Vultr Hosting Database Error
Should I reset wp database?
Problem with admin area
How to Install and Setup Breeze WordPress Cache Plugin?

Brother, then what is the actual process in PHP MyAdmin Optimize Tables?
Can you explain that please?


Didn’t know this. Just uninstalled it on a site. Will check db.


Also delete useless tables created by plugins using WPDBSpringClean Plugin.


Wp-sweep or Wp-optimize, which one you would prefer?


WP Sweep, I would prefer because it is fast.

Additionally, I liked this plugin WPDBSpringClean, as recommended by @Hitesh


Bookmarked. Gonna give it a try in near future, thanks. Btw WP sweep & WPDBSpringClean used for same thing,right?


Both are little different. Try it.


What this can help us to improve website speed


Yes, it can help in improving wp-admin area and overall site performance.


Thanks sharing the information above. I personally use WP-Optimize for my blog and getting good results. Also easy to use.