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 -
- 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?
Install & Activate WP Sweep Plugin in WordPress
Go to Plugin UI: Tools > WP Sweep
Here, everything you can sweep at once.
However, I would not recommend following this shortcut which may hurt you back.
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.
By clicking on Sweep button next to each details, you are going to clean up the Junk data.
If you are running a busy WordPress site with below Redirection plugin, Beware of logs!
Keep below settings to avoid bloating database.
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,