How to Clean Up Your WordPress Database for Improved Performance

WordPress Database is the storehouse of all the contents and data of your website. Everything that you create, modify and work on in your website is stored in your database. Every post and pages of your website and all the comments made by your readers on those posts are stored in some form in the database. It also stores all the links, form entries, settings and portfolios items. The guide shows how to clean up your WordPress database for improved performance.

Over time your database accumulates many unused tables, redundant records and unnecessary data. When you change themes or uninstalled plugins, they may leave traces of information lying around your database. This is just taking up space and makes your database size larger. The bigger the database is, the longer it takes for server to retrieve information from database. A larger database can seriously slow down loading of your site pages.

How to Clean Up Your WordPress Database for Improved Performance

Slow loading website frustrates readers, increases bounce rate and drives your visitors far away from your website. You can lose subscribers and customers with your annoying slow loading website. Even Google has included site speed as a new signal in Search Ranking Algorithm. So you must regularly clean up your database to decrease load on servers. Also if you have limited space in your hosting plan, getting rid of unused data is a good idea to empty more space.

Backup Your Database First!

Database is a very dangerous place to be messing around if you have inadequate knowledge. Even if you have expertise with database, any mistake by deleting wrong tables or data can be dangerous. You may end up crashing your entire website. So it is always better to be safe than sorry.

Make sure you have a working backup and know how to restore your site before performing any action in your database. Here are the lists of top 5 WordPress backup plugins you can check out.

  1.       BackupBuddy
  2.       UpdraftPlus
  3.       BackUpWordPress
  4.       Duplicator
  5.       BackWPup

We have tons of articles in our website to help you about backing up your database. You may want to check them for learning to back up before proceeding further.

Methods for Cleaning Up Your WordPress Database

1. Deleting Unused Plugins

This is the easiest but most effective method. Take a look through your plugins list and determine the unused and unnecessary plugins and toss them away. It is a good idea to completely deleting a plugin instead of just disabling them.
How to Clean Up Your WordPress Database for Improved Performance

2. Deleting unused tables.

Unused tables can be removed from your database manually through a database management tool such as phpMyAdmin. However the better and safe option to remove unused table is by using the plugins like WPDBSpringClean that will identify the unused tables and help you to delete it correctly.

3. Optimize and Repair Your WordPress Database from phpMyAdmin

If you are doing a manual clean up task, phpMyAdmin is a common tool to manage database. phpMyAdmin is a MySQL management tool that your hosting plan uses. You can easily find phpMyAdmin in your cpanel.

phMyAdmin

Optimization of database means simply re-sequencing, compressing, managing index paths, defragmenting, etc. Optimizing your database will remove the overhead and reduce the overall size of your database. First enter into the database where your WordPress is installed. Click on the “Check All” box, select “Optimize table” from the drop-down menu, and then click on the “Go” button as shown in image below.How to Clean Up Your WordPress Database for Improved Performance

After the optimization process is complete you will get a confirmation message.

confirm

You can also use ‘Repair table’ option to fix any corrupted table.

repair-tble

If you want to delete unnecessary data of your database using just PHPMyAdmin, you’d have to go table by table, identifying the specific data you want to delete. Then you have to drop the data or enter MySQL commands to delete that data. Unless you are sure about not making mistakes, using PhpMyAdmin is not the recommended method to permanently delete data.

Also Read:   How to Roll Back WordPress Plugin to Previous Version
4. Using Plugins to clean up the Database.

Using Plugins is a safe and effective way to clean up your database. Plugins can scan and evaluate your database and will warn you against actions that can potentially break your site.

Here are few top rated Plugins you can give a try

5. Automatic Database Optimization tool of WordPress

WordPress also has automatic tools to repair and optimize your database. You can find out about this tool in Automatic Database Optimizing section of the WordPress.org guide on wp-config.php. To use this tool first you have to add this line to your website ‘wp-config.php’ file.

define( ‘WP_ALLOW_REPAIR’, true );

After adding the above code to wp-config.php, you can use the optimization tool. Just go to address http://www.yourwebsite.com/wp-admin/maint/repair.php and this will take you to optimization page. Just replace the address above with you website address.
How to Clean Up Your WordPress Database for Improved Performance

You can use this tool to repair and optimize each database tables.

For safety, after complete the optimization and repair process delete the line define( ‘WP_ALLOW_REPAIR’, true ); from your wp-config file that you had added earlier.

6. WordPress revision system

WordPress revision system of WordPress stores a copy of every draft. This is useful to revert back to older copies of articles and check earlier drafts. But WordPress has no limitation on the number of revisions that are saved. The corresponding revisions and auto saves can occupy dozen and hundreds of rows in your database.

To reduce the number of revisions that are saved, simply add the following code to your wp-config.php file.

define( ‘WP_POST_REVISIONS’, 2 );  You can use plugins to deal with this problem of revisions eating up your daabase space. Some good plugins for this task are Optimize Database after Deleting Revisions and Better Delete Revision.

7. Spam comments

If the articles in your website get lots of spam comments, then the chances are they are eating up spaces in your database. By default, spam comments are automatically deleted in 30 days. But In case of many spams it’s a good idea to manually delete the spam comments to free space. You can use WordPress “Empty Spam” button to the spam comment page that allows you to permanently delete all spam comments instantly.

delete-comments

Another good idea is using anti spam plugins like Akismet and WPCommentCleaner  to prevent spam comment from coming. You can check our article “How to Remove Spam from WordPress Comments” to have detail knowledge on defending against spams.

There are many more effective ways to clean up your database which may have been missed out in this article. However the methods mentioned here are good enough to clean up any kinds of junks in your database. I hope the article was helpful thank you.

The following two tabs change content below.
Kantiman Bajracharya

Kantiman Bajracharya

Kantiman Bajracharya is a freelance web developer. He is a computer geek who has a Bachelor’s degree in Computer Engineering. He has earned lots of satisfied customers while working for numerous successful projects. He is also a WordPress theme creator and web article writer. On free time he likes reading philosophy books, traveling and playing chess.

Share This Post