If you are a WordPress user, it is highly recommended to clean up WordPress database on a regular basis. After all, as your WordPress site grows, your database simply accumulates plenty of extra data for unused plugins and themes, spam comments, post revisions, trashed items and many more, all of which can slow down your page loading speed to a large extent. This time, we’d like to showcase the easiest way for the cleanup with the help of WP-Sweep or WP-Optimize plugin.
Clean Up WordPress Database using WP-Sweep
This is one of the most easy-to-use database cleanup WordPress plugins, without any requirement of technical skills. With it, you can optimize and clean your database with a single click, or optionally sweep the items of blog posts, comments, user meta, transients, database tables and some more.
To start cleaning, you firstly need to install and activate this plugin and find it from the Tools tab of your WordPress admin. Then, click the Sweep button from the dropdown menu.
As this plugin automatically analyzes your website database, you can be presented with a clear report about how much clutter you can sweep. The report is categorized into multiple groups just like the following screenshot.
- Post Sweep – This category is mainly about your revisions, auto drafts and removed posts. Besides, there is an oEmbed Cache option that is for the damaged embedding codes for Vimeo videos and YouTube. Upon clearing, WordPress will try to fetch the new embed codes for proper display.
- Comment Sweep – This one is for your spammed comments and deleted comments. As for the unapproved comments, you’d better make sure all of them are bad comments before cleaning them.
- Terms Sweep – As some of the unused terms are your drafts, you need to make sure that you have no drafted posts before sweeping this option.
- Option Sweep – This category is mainly about transient options that are used for storing your caching data. Note that what this plugin clears are all the expired transient records, so you will never lose anything upon the sweeping.
As for the clearing of these items, you can check the detailed information of each category by clicking the Details button, and hit the Sweep button optionally based on your real situations. Or, you simply need to scroll down to the bottom and click the Sweep All button to clean up all the options in one time.
Clean Up WordPress Database using WP-Optimize
This is another widely used WordPress plugin for the cleanup and optimization of your database with extensive functions. Upon the successful installation and activation of it using your WordPress dashboard, you can find a new tab named as WP-Optimize in the left-hand column of your website back-end. Simply click it.
Now, you can be presented with a list of clean-up options including post revisions, automatically drafted posts, posts in trash, spam comments, comments in trash, comments in moderation, transient options, database tables, pingbacks and trackbacks. You can choose them optionally for the cleanup. Then, click the Process button.
In addition, the WP-Optimize plugin allows the automatic cleanup for your WordPress database on a daily, weekly and monthly basis. For this, you simply need to click the Settings button. Then, check the box to enable the scheduled clean-up and optimization, select the scheduled type and choose the cleanup options. Here, you can also enter your current email address to enable the email notification for each cleanup.
After all of these, you simply need to click the Save Auto Clean-Up Settings button. And this plugin can schedule the automatic clearing of your WordPress database based on your ultimate requirements.
Special Suggestions for the Utilization of These Two Plugins
Which Plugin to Choose
Without doubt, both of these two plugins are powerful enough to clean up your WordPress database in an extensive manner. However, when choosing between them, you’d better consider the following two situations.
- If your website is fast growing which may result in a large number of useless items on your database, you’d better try the WP-Optimize plugin to enjoy its auto cleanup feature.
- If you site is under a stable stage that only requires the constant updates, you’d better try the WP-Sweep plugin. After all, unlike WP-Optimize that operates the direct deleting on SQL queries, this plugin runs the proper WordPress deleting function, minimizing the possibility of orphaned data effectively.
Besides, WP-Sweep categorizes the cleanup items with more subdivisions and detailed information, so that you can choose to clear them in a better way.
Backup Before Cleanup
No matter what changes you want to make on your website, you’d better always keep a backup file in case any unexpected situations. And the practice of cleaning up your website database is no exception. After all, changes made by this practice are irreversible. Therefore, do not forget to back up your WordPress site before clicking the clearing button.
Some Other Useful Tips to Clean Up WordPress Database
Tip 1: Remove WordPress Revisions
WordPress has a default feature named as revision, which makes the WordPress database unnecessarily large as your website grows.
This feature is added since WordPress version 2.6. With it, all the changes you make on your posts and drafts will be stored every two minutes as revisions. With them, you can revert back to the older versions of your posts or check some earlier drafts. However, as these auto-saved files are stored as separate entries in your database and WordPress does not set any restrictions on the number of revisions for each post, this feature simply enlarges your database greatly. Sometimes when you are working on a lengthy post, this feature can lead to tens of revisions being stored.
In this case, having your revisions cleared regularly is important. This post simply tells you how to carry out this practice using the Better Delete Revision plugin.
Besides, you can also limit the number of revisions that are saved for each post. For this, you can add the following code into your wp-config.php file. The character X refers to the limit number.
define( 'WP_POST_REVISIONS', X );
Tip 2: Remove Spam Comments
As time goes, you may receive a lot of spam comments from both humans and robots. These spam messages may take up a large number of rows in your wp_comment table. Therefore, you need to clear them up on a regular basis.
Among all the tools to prevent spam comments, we highly recommend Akismet. It has a default function that discards all the pervasive spam automatically. You can check this Akismet tutorial to get further information.
If you do not want to install any additional plugin, you can also navigate to your Discussion Settings of WordPress admin. Here, you can decide to close the comments on blog posts that are older than a specific number of days. Note that the default number is 30 days. You can reduce it to one week, reducing the spam comments that your site receives.
Tip 3: Empty the Trash
WordPress has a trash system that is used to store all your deleted items. This means whenever you delete your blog posts, media files, comments, plugins and many other items, they will be sent into your trash folder. This feature prevents you from deleting things in accident.
However, if you remove items regularly or in a massive amount, your trash folder may take up your database greatly. In this case, once you confirm that you no longer need the items that are deleted temporarily, you’d better empty your trash folder all the times.
Tip 4: Delete WordPress Transients
WordPress transients offer a standardized and simple way for saving cached data in the database in a temporary manner. Generally, the transients are stored in the option table of WordPress database.
To avoid these data that slows down the page loading by adding bloat to your database, you’d better delete all the expired transient records regularly. For this, we highly recommend the Transient Cleaner plugin.
Tip 5: Remove Unnecessary Plugins
If you go through the plugin settings page of your WordPress admin, you may find a list of plugins that are not necessarily useful for your website. For these tools, you’d better disable them, and then delete completely from the Inactive list. This is because every plugin stores some settings and data in your WordPress database, accumulating extra bloat over times on your site.
Tip 6: Clean wp-commentmeta
This table of wp-commentmeta may increase your database size greatly due to the utilization of Akismet plugin. Therefore, if you are using this security plugin to prevent spam, you’d better run the following SQL queries to reduce the database size.
Note that these two queries need to be processed with the help of WP DB Manager plugin. Besides, as you may change your database name during WordPress installation, you’d better check the table name before running the queries.