How To Clean Up And Optimize Your WordPress Database

How To Clean Up Your WordPress Database 2022

I love WordPress. I’ve used it for years as a content management system (CMS) for everything from personal blogs to client projects. Its ease of use and flexibility are what first attracted me, but its never-ending list of plugins is what made me stay hooked, and I’m not alone. Currently, over 30% of all websites use WordPress to manage their content. The downside is that over time the database can get a little messy if you don’t take proper care of it. It’s critical to keep your database clean and optimized to keep things running smoothly on your site and prevent security issues or error messages that may cause downtime. It’s actually pretty easy to do this task, so don’t let it stop you from keeping your website in good shape!

What Is The WordPress Database?

The WordPress database is a collection of all the content on your website: posts, images, pages, and custom post types (such as products and events). It also stores information about your site visitors, such as their IP address, location, browser type, and operating system. Each time you visit a website using PHP or MySQL (a programming language for building websites), it creates an entry in the database that contains all the information about that visit — e.g. when it happened and where from. Your web host will also have its own copy of this database on its servers.

Why You Should Clean Your WordPress Database

The WordPress database is the heart of your website. It’s where all of your posts, pages, comments and other content are stored.

If you have a lot of traffic and a large number of posts, your database will grow over time. Once it reaches a certain size, it can slow down your site or even cause it to crash.

Why would you want to clean your WordPress database?

  • To optimize the performance of your site, which will improve load time and help prevent crashes.
  • To keep it from becoming bloated, which can cause slow loading times.
  • To avoid security vulnerabilities by removing old or unnecessary data from the database that could be used maliciously against your site.

Good WordPress Database Cleanup Practices

Following good WordPress database cleanup practices will help keep your website database from becoming too big.

Prevent Comment Spam

Unwanted comments can greatly increase the size of your WordPress database. You can reduce this effect by disabling trackbacks and pingbacks and using anti-spam plugins such as Akismet, Antispam Bee, and CleanTalk.

I’ve found that if spam becomes a major problem on your website, you may want to consider following my lead and disabling comments altogether.

Limit Post Revisions

WordPress saves a draft every time you publish a post, page or custom post type. It also saves your content automatically every 60 seconds. These are known as auto-saves or auto-drafts.

I’ve always found the revision system useful, because it allows me to compare older drafts of articles. However, it can be a great waste of resources if you don’t manage your revisions properly. WordPress saves only one auto-save for each post or page, but there is no limit to the number of revisions that are stored. This means that WordPress could end up storing hundreds of variations of an article on its servers.

A simple way to solve this problem is to limit the number of post revisions that are saved by your WordPress blog. To do this, add the following line to the wp-config.php file:

define( ‘WP_POST_REVISIONS’, 3 );

The WordPress revision system can be disabled with the following line.

define( ‘WP_POST_REVISIONS’, 0 );

Although some website owners use the above code to disable post revisions altogether, I advise against this. It leaves you with no backups of draft articles, and deleting revisions can be a bit tedious. A better option is to limit the number of post revisions that are saved and then delete those revisions once the content has been published.

Remove Unnecessary WordPress Plugins & Themes

If you’re not using a certain plugin or theme, uninstall it! You can do this by going to Plugins in your WordPress dashboard and then clicking on the little gear icon next to the plugin name. This will bring up some information about that plugin, including its version number, author, etc. Click on Deactivate in order to disable the plugin without deleting it from your site. You can always reactivate it later if you need to.

If you’re having trouble finding a specific plugin or theme, try using Google or another search engine to look for “WordPress [plugin name]” or “[theme name]”. You may also want to try the following:

Check if there’s an update for the plugin or theme by going into Settings > Updates and clicking Update Now. If there is an update available, it will download automatically when you click Update Now. If there isn’t one available yet but there will be soon, you’ll see an option labeled “Notify me when a new version is released.” Clicking this will notify you via email when an update becomes available for that particular plugin or theme

Remove Unused Media

The best way to clean up your WordPress database is by removing unused media. This sounds complicated but it’s actually quite simple. Here’s how you do it:

1) Log into your WordPress Dashboard, then go to Dashboard>Media Library.

2) Click on “Unused Media” at the top of the screen (it looks like an eye). You should see a list of images that are no longer attached to any posts or pages on your site. If there are any files in this list that you don’t need anymore, delete them by clicking “Delete Permanently” at the bottom of the page.

How to Clean And Optimize WordPress Database

Use phpMyAdmin.

If you’re comfortable using phpMyAdmin to edit the WordPress database, you can use the Optimize Table feature to reduce storage space and improve I/O efficiency. Experienced users can also do this using the MySQL statement OPTIMIZE TABLE.

If this is all too technical for you, you can use popular WordPress database cleanup plugins that let you optimize your WordPress database at the click of a button.

Use a plugin.

There are many ways you can optimize your WordPress database. But the easiest way is to use a plugin that does it for you. There are many plugins such as WP-Optimize, WP Database Backup, advanced database cleaner and WP Database Reset.

Backup Your WordPress Site Before Cleaning The Database

Before you start cleaning up your WordPress database, it’s a good idea to make sure that you have a backup of your site. It sounds obvious, but we can’t stress enough how important this is. If something were to go wrong during the process and you weren’t able to restore from your backup file in time (which can take hours), then all of the hard work you put into optimizing your WordPress site would be lost.

So how do I back up my website?

There are two main ways: using a plugin or manually exporting/importing files from/into another directory on your server via FTP client software like FileZilla or Transmit (for Mac). We recommend that new users start with plugins because they require less technical knowledge than manually exporting files via FTP clients. For example, here’s what the BackupBuddy plugin looks like when activated:

Remove Post Revisions, Spam Comments, Unapproved Comments, and Trash From WordPress Database

  • Remove Post Revisions

You can remove post revisions via the WordPress editor screen. On the left side of the screen, click on Settings then Media. Scroll down to “Revisions” and change it from 1 day to 0 days or less (with 5 minutes as a minimum). This will prevent your database from getting bloated with extra data that doesn’t need to be there.

  • Delete Spam Comments and Unapproved Comments

Removing spam comments is quite easy. Just go into your WordPress admin dashboard > Comments > Spam and click on the Delete all spam comments button at the bottom right of page. You can also delete any unapproved comment by going into Your blog > Posts > All Posts area where there’s an Unapproved link/button above each post which allows you to delete all or selected unapproved comments in one click! Don’t forget about the Trashcan feature for quick deletion routine maintenance too!

Reduce the Size of Your Post and Page Drafts in WordPress

Now that you know how to optimize your database, it’s time to put those new skills into action. To start, here are a few tips for cleaning up your drafts:

  • Delete old drafts. If you have drafts that are no longer relevant or useful, delete them!
  • Delete drafts that are no longer needed. Sometimes we create a draft but never publish it because it wasn’t as good as we thought and we think “I’ll do better next time.” In reality, this is just wasting space on our WordPress databases by keeping a bunch of files around with no real purpose in life other than making us feel like we accomplished something when really all they do is take up space and potentially slow down our websites too much if their sizes are large enough (which most of ours probably aren’t).
  • Delete drafts that are no longer wanted by anyone – whether they’re yours or someone else’s! Chances are there’s at least one person out there who didn’t want this content created or published so why keep storing it away where only they can see it?

Delete Orphaned Data From Your WordPress Database

Orphaned data is when you have orphaned posts. Orphaned files are those you’ve deleted but WordPress hasn’t yet gotten around to removing from the database, even though there isn’t a post with an attachment for them. When this happens, it can cause performance issues and security issues in your site as well as become an issue of privacy or legality if these posts contain sensitive information that shouldn’t be publicly available anymore.

To clean up orphaned data:

  • Delete old attachments
  • Remove useless drafts
  • Delete spam comments

Optimize MySQL Tables In Your WordPress Database Using SQL Commands Or A Plugin

  • Optimize MySQL Tables Using SQL Commands

Optimize MySQL Tables Using SQL Commands

The WordPress database is just like any other database. You can use the command-line interface to view and change its contents. This can be useful when you want to optimize your database for speed or reduce its size.

The wp-config.php file contains several options that you can use to optimize your site’s performance. These settings include MySQL table optimization (OPTIMIZE), custom character sets and collation, and connection timeouts:

define(‘WP_CACHE’, true); // Whether to enable the WordPress Object Cache

define(‘WP_DEBUG’, false); // Disable all error reporting if set to true

define(‘WP_MEMORY_LIMIT’, ’64M’); // Memory limit for PHP, in megabytes

define(‘AUTOMATIC_UPDATER_DISABLED’, false); // Disable all automatic updates on your network; set to true by default (disable).

  • Optimize MySQL Tables Using A Plugin

I’ll start with the more technical, but less risky way to do it. To optimize your tables in WordPress using SQL commands, simply log in to your cPanel account (usually on a domain level) and open up phpMyAdmin. In this tool, you’ll be able to create new databases and edit existing ones. You can also change the table structure of your database if you want (but don’t do this unless you know what you’re doing). Once logged in, run these three queries:

There are several ways to clean and optimize a wordpress database.

There are several ways to clean and optimize a WordPress database, but one of the easiest is by using a plugin.

The most popular plugins for cleaning and optimizing your database are: Clean Up Database, WP-Optimize, and WP-Sweep (which also adds some security features). You can read more about each in our article on How To Clean & Optimize Your WordPress Database.

If you need more control over what is deleted from your database, or if you prefer not to use plugins at all because they’re not necessary for this process, then manually cleaning up your site’s database may be the way to go for you.

Best wordpress database plugin

The WordPress database is responsible for storing all of the information and customizations added to your website. It’s an essential part of your site, but over time it can become bloated, slowing down your site and making it more susceptible to errors.

The best way to clean up your database is by using a plugin that will optimize it for you. There are several different plugins that do this, but here’s a list of some of the best ones available:

Wp Rocket

WP Rocket is a WordPress plugin that offers page caching, lazy loading for images, CSS and Javascript optimization, and database optimization.

The WordPress database cleanup page has options for deleting post revisions, auto-drafts, trashed posts, spam comments, trashed comments, and transients. WordPress tables can also be optimized.


WP-Optimize This is one of the most popular and effective plugins for cleaning up your database. It allows you to clean out post revisions and other unnecessary data from your database. You can also schedule regular cleanup jobs so that you don’t have to worry about doing it manually every week or two.

WP-Optimize’s database table scanner is one of the plugin’s most useful tools. It highlights tables that are not being used and shows the number of records and data size for each one. A link to the associated WordPress plugin is provided for each table, and tables that are not required can be removed at the click of a button.

How do I reduce the size of my WordPress database?

Can you help with reducing database size in WordPress? Perform data analysis on MySQL databases on MySQL tables. Remove all automatically generated posts. Remove any page revision or update. Remove everything you want from a trash folder. Remove any comments tagged spamming. Elimination of expiring transients.


WP-DBManager This plugin provides a wide range of options for optimizing your database such as trimming unneeded whitespace, removing unused meta fields and optimizing tables with just one click. It also has an option to automatically generate backups before making changes so that if anything goes wrong while modifying your WordPress database you’ll have a backup copy ready to restore from.

WP Database Reset

The WP Database Reset plugin gives you the ability to reset your entire WordPress database with one click. Alternatively, you can choose to clear out only certain tables in the database. This is a simple and secure way to go back to a point in time where your database may not be as cluttered.

The entire process takes only one click. All settings are configured on one page. You type in the tables you want to be deleted, along with a security code to ensure it’s you. It’s recommended that you back up your database before running this plugin.

WP Database Backup

The WP Database Backup plugin is best used with a plugin for cleaning your database. Sometimes this is a great security measure, but other times you simply want to have a backup of your data prior to cleaning everything out.

The plugin offers two basic features, one to back up your data and the other is for restoring. You can download your backups, have automated email notifications sent out whenever a backup is completed and set a schedule for automatic backups. We like how user-friendly it is, especially considering you can leave it set to run automatically in the future.

Better Search Replace

Better Search Replace provides a need for companies to transfer their websites to a new server. You wouldn’t have this plugin installed on your website at all times, but it sure comes in handy when you’re migrating, since your database usually needs to go through a few modifications during the process.

For example, your links and media items may not have the right address. You may also discover that some of your tables need fixing. Regardless of the situation, Better Search Replace is here to help out.

Advanced Database Cleaner

The Advanced Database Cleaner focuses on deleting items in your database that are either unnecessary or causing problems on the server. It deletes old revisions that are no longer needed, for example, and also deletes trackbacks, pending comments, and old drafts.

If you own a website and neglect to clean out your database, you may find it becoming cluttered and slowing down. The Advanced Database Cleaner tool provides a basic settings module as well, with options for setting how often you would like to clean the database and if you want to exclude any files from the cleaning.


How do I reduce the size of my WordPress database?

Can you help with reducing the database size in WordPress? Perform data analysis on MySQL databases on MySQL tables. Remove all automatically generated posts. Remove any page revision or update. Remove everything you want from a trash folder. Remove any comments tagged spamming. Elimination of expiring transients.

How do I optimize my WordPress database?

To manually optimize a WordPress page, you need PHP MyAdmin installed on your hosting account. You need to log onto Cpanel, then open PHPMyAdmin tools, and go to database. Specify what databases you want optimized for. Choose Check for an optimal table layout.

How do I clean my WordPress database?

Can you clean a site using WordPress? Please protect the WordPress database. Install WPSoptimization. Taking the rubbish off our database. Remove old plugins from the table data. Plan yearly data cleansings. Using another plugin to clean up the database.

Which DB is best for WordPress?

Top six WordPress Plugins. UpdatePlus Backup & Recovery. Vault Press. Optimizing databases for deletion. WPPDB Manager. Database of participants.

How do I clean up my WordPress database?

What is the best way of cleaning a WordPress database? Create a backup in WordPress. Install WpOptimize. Remove all unused data. Remove tables from older plugins. Plan a regular cleaning of the database. You should also use another plugin when cleaning up databases.

How do I use advanced database cleaner?

Automated database cleaning. Installation of Advanced databases cleaner plugin by Younes JFR. When installed, click on the new WPDB Cleaner button on the Dashboards menu. By default, your cleaning is done in General.

How do I manually clean my WordPress database?

How do I remove the cache from my website? Backup WordPress databases. Install WPP-Optimized. Removing all unused items in my database. Remove the old plugin table. Set recurring database cleaning. You can clean the database using another plug-in.

What is database cleanup?

Data Clean-up is the step used in finding a missing or incomplete data set in the system and then re-using, changing, or deleting the data.

Does WordPress have a database plugin?

WordPress Database plugins can organize form submissions to optimize your website and store important documents. A robust and effective website database is necessary to manage the whole thing.

How do I remove plugin data from WordPress database?

Deleting plugins is the necessary step. Remove them from the dashboard. Use the FTP connection for the file. Please erase the file. Database. Open Mysql and delete my plugins – table – wp_options.

How do I get rid of unused WordPress plugins?

The deactivation/removal of plugins is relatively straightforward. Navigate to plugin areas on the dashboard and select the plugin that needs to be removed from the list. If you go under the name of the plugin there is a Deactivation option.

How do I clear my WordPress database?

I need help cleaning up my WordPress database! Backup WordPress databases. Install WpOptimize. Dispose of the garbage. Delete tables from the older plugins. Plan on continuing to clean the databases. Using Other plugins Clean Databases?


Look, there’s no doubt that the WordPress database can get big and messy over time. If properly cleaned and optimized, however, it will run smoothly and efficiently under the hood. So go ahead and try one of our methods. Cleaning your WordPress database is not very difficult at all with our easy-to-follow guide!