How To Reduce WordPress Database Size To Improve Blog Performance

There are two important components of a typical WordPress installation:
  • WordPress files stored on your server
  • WordPress database
It’s an essential for you to clean up your WordPress database and reduce its size from time to time.
Over time, your WordPress database has accumulated many redundant tables, unused records, and many entries which you can remove without affecting your website.
This is a must-do process for every WordPress user to keep the size of their database at a minimum and keep their WordPress blog loading quickly.

This will help reduce the load on your server and your WordPress performance will improve dramatically.
In this tutorial, I will take the example of Tech2aim

WordPress database which is 286.3 MB and drastically reduce it’s size. 



You can follow this guide step-by-step and perform these tasks on your own blog.
Note: A few of the points require a little technical know-how, and if you find yourself questioning, feel free to ask in the comments or skip that step entirely. 

Tutorial: How to Reduce WordPress Database Size

Step 1: Take WordPress Database Backup (IMPORTANT)
Taking WordPress Database Backup
This is an essential step.
In my case, I have used my hosting company’s backup feature (WPEngine backup) to take a complete backup of the database and all included files.
You can also use the WP-DB Manager plugin to take a backup of your database file. You can find a tutorial over here. I highly recommend the WP-DB Manager plugin because we will be needing to run a few SQL queries, empty, and drop database tables (all of which this plugin can do).
Step 2: Disable AND Delete Unused WordPress Plugins
delete unused WordPress plugin
Go through the active plugin list on your WordPress blog and disable those plugins which you are not using anymore. There might be plugins that you use once in a while, but I suggest you disable them now and re-install them when they’re needed again.
Our goal for today is to completely optimize the database size.
Only disabling unused plugins will not be of much help here, so make sure you also delete those unused plugins.
Speaking of useful plugins:
Step 3: Delete All Spam Comments, Trash Posts, and Post Revisions
Whatever comments you have in your spam and trash folders, delete them.
Similarly, delete all posts from the trash folder and delete all post revisions.
cleanup-wordpress-database

Step 4: Find and Clean Orphan Tables
orphan-wordpress-tables
Install the WP Advanced database cleaner WordPress plugin & and follow this tutorial.
This plugin will find orphan and unused tables in your database. Using this plugin will help you clean all such tables.
This is a quite critical step and does it only when you are sure of the table names which you are not using.
If you are confused, skip this step.
  • Note: Deactivate the plugin after using it.
Step 5: Remove Unused Meta Values From Database 
(Caution: Technical knowledge needed)
This is something I do once a year and suggests you do it only if you are accustomed to phpMyAdmin.
This won’t bring down your database size significantly, but it is useful if you are highly determined to clean up your WordPress database.
Step 6: Use MySql Queries To Reduce Database Size
One of the tables which are a major cause of increased database size is “wp_commentmeta” due to the Akismet plugin.
Before running the below-mentioned query, my wp_commentmeta size was 146 MB.
After optimizing, it reduced to 16.1 MB.
Here are two queries which you need to run. Use the WP-DB Manager plugin > Run SQL query option to execute these queries from the WordPress dashboard. 
  • Run both SQL commands separately.
DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
DELETE FROM wp_commentmeta WHERE meta_key LIKE '%akismet%';
Note: For some WordPress installations, there is a chance your database table names might be different from what is used in the above code. It could be something like “wp_commentsmeta”, so don’t forget to check your DB table names and replace them accordingly.
Here are couple more SQL queries which will be useful to reduce database size:
DELETE FROM wp_postmeta WHERE meta_key = "_edit_lock";
DELETE FROM wp_postmeta WHERE meta_key = "_edit_last";
Step 7: Empty and Drop Unused Database Tables
Again, this step is for those WordPress users who have a fair knowledge of WordPress tables.
Under the WP-DB Manager plugin, you will find an option to “Empty/Drop Table” and from there you can see the list of all the tables in your WordPress DB.
Here you can empty those logs which are not useful and drop those tables which were created by any plugins that you are not using anymore.
For example, I removed “wp_roostsettings” which was created by one of the plugins I deleted in Step 2.
Step 8: Optimize Database and Be Amazed
If you have followed all of the above steps as mentioned, it’s now time to optimize your database and see how much size you have freed up.
You can optimize your database using the “Optimize” option of the WP-DB Manager plugin, or you can use the WP-Optimize plugin. I have shared a guide before on database optimization here.
As mentioned above, my WordPress database size was 286 MB before cleaning up, and after all of the above-mentioned steps, my database size dropped to 96.7 MB.
That’s a huge reduction of 189 MB!
Overall, if you have a busy WordPress site, you should clean your WordPress database once every two months, or at least optimize your WordPress database once every two weeks.
Go ahead and start working on reducing your WordPress database size and let me know how much space it was before and how much space it is now.
Speaking of fine-tuning your WordPress blog:
Share on Google Plus

About Admin

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis.

0 Comments:

Post a Comment