Whenever you save a page or post in WordPress it creates a revision. This occurs in both drafts and already published posts that are updated. Revisions can be helpful in case you need to revert back to a previous version of your content. However, they can also hurt the performance of your WordPress site. On large sites, this can add up very quickly to thousands of rows in your database which are not necessarily needed. And the more rows you have the larger your database in size, which takes up storage space. Follow the steps below on how to delete, limit, and disable WordPress revisions for faster performance.

Optimize WordPress Revisions

It is not uncommon for older sites to have 100+ revisions on their main pages. This is simply due to years of editing and updating content. Let’s say for example a site has 700 pages or posts with 150 revisions on each, this would be over 100,000 entries in the database. This happens a lot more frequently than you might think. Thankfully, there are a couple easy optimizations you can make to ensure this doesn’t hurt the performance of your site.

Delete WordPress Revisions

If you are starting a new site, you can skip to the next section as you won’t have existing revisions. If you are on an older site, the first thing you will probably want to do is clean up and delete the hundreds or thousands of WordPress revisions. This is where a lot of the magic happens, and you can free up space in your database. If you are trying to do this with a MySQL query, be very careful as there are a lot of bad snippets of code floating around the WordPress repository forums with bad information. Many suggest queries that sometimes delete a relationship needed to make dashboard links work.

We recommend using the free WP-Sweep plugin. We don’t recommend the WP-Optimize plugin or Optimize Database after Deleting Revisions plugin, even though they are very popular. They are on our banned list of plugins as they been known to cause serious issues for some Kinsta users.

Running any type of database plugin could break your site if not done correctly. We always recommend backing up your MySQL database beforehand. If you are not comfortable doing this, please check with a developer first.

Step 1

Download and install the free WP-Sweep plugin. As of writing this, the plugin has over 60,000 active installs with a 4.5 out of 5 rating. You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins.

Step 2

Under “Tools” click into “Sweep.” You will then see revisions, along with the count. You can click on “Details” to see a list of the posts which will be impacted. For performance reasons, only 500 items are shown at a time.

Step 3

Once you’re ready, click on “Sweep” next to Revisions.

You will then see a short confirmation of the total number of revisions removed. Since this is on a small test site, there aren’t that many. Larger sites will typically have quite a few.

Delete WordPress Revisions With WP-CLI

Another option, especially one that WordPress developers might like, is the ability to delete post revisions with WP-CLI. Here is an example of a WP-CLI command:

$ wp post delete $(wp post list --post_type='revision' --format=ids)

You can read more about the wp post delete command in the WP-CLI documentation.

We grew our traffic 1,187% with WordPress.

We’ll show you how. Join 20,000+ others who get our weekly newsletter with insider WordPress tips! Subscribe Now Success! Thanks for subscribing You will receive the next issue of the Kinsta Newsletter within a week. Subscribe to the Kinsta newsletter Subscribe I agree to the Terms and Conditions and Privacy Policy

Limit Number of WordPress Revisions

After you have cleaned up your old revisions, the next step is to limit the number of WordPress revisions that you allow. This can be a great stop-gap measure to ensure that the revisions don’t pile up again. Perhaps you want to save 3 revisions. WordPress will keep that number and delete any previous ones. You can also use wp-revisions-cli to cleanup post revisions based on the number you set below.

Step 1

Open your wp-config.php file. You will need to add some code. This is typically located in the root of your WordPress site directory and you can access it via FTP.

Important! Editing the source code of a WordPress theme could break your site if not done correctly. If you are not comfortable doing this, please check with a developer first.

Step 2

The code below needs to be inserted above the ‘ABSPATH’ otherwise it won’t work. Again, you can change the number to however many of revisions you want to keep stored in your database per page or post.

define('WP_POST_REVISIONS', 3);

It should look something like the following.

Alternatively, you can also use a premium plugin like perfmatters (developed by a team member at Kinsta), which allows you to limit the number of stored WordPress revisions or disable them altogether.

Disable WordPress Revisions (Optional)

The last option you have is to simply disable WordPress revisions altogether. Typically option 2 above is the most commonly used method. However, if you are on a single author site, you might simply want to get rid of them altogether. Remember, it will still save a draft, it just won’t have revision restore points.

Step 1

The steps are the same as limiting revisions above. Open your wp-config.php file.

Step 2

The code below needs to be inserted above the ‘ABSPATH’ otherwise it won’t work.

define('WP_POST_REVISIONS', false);

It should look something like the following.

Alternatively, you could also use a free and lightweight WordPress plugin called Disable Post Revision. Simply install it, click into “Writing” in your dashboard, and select the post types for which you want to disable revisions.