Fine tuning WordPress revisions

Overview

WordPress saves a revision for every draft or update, which can bloat your database. You can limit or disable revisions — with an SQL query, or by editing the WP_POST_REVISIONS value in your wp-config.php file. This article explains both methods.

Background

The WordPress revisions system stores a record of each saved draft or published update. Though helpful, this has the potential of overloading your databases, especially if you're making numerous changes or spending a lot of time creating a post. There are several ways to fine-tune the amount of revisions your WordPress site saves, which will decrease the load on your databases and keep your site speedy.

How do I adjust revisions?

Depending on your preference, you can make revision adjustments with an SQL query or within the wp-config.php file for your WordPress site.

Using an SQL query

If you do not wish to add another plugin to your WordPress installation, then you can run a simple SQL query to remove revisions:

  1. Connect to your database via SSH or with a MySQL client such as MySQL Workbench.

  2. Make a note of the table prefix. It's the $table_prefix value in your site's wp-config.php file.

    The table prefix may appear as wp_, but it’s very possible to have a random string of letters such as wp_qch9en_.

  3. Run the following SQL command:

    DELETE FROM wp_posts WHERE post_type = "revision";

    This removes all revisions currently stored in the database. Make sure you enter the correct table prefix into the query. In the example above, the prefix is wp_.

How do I edit the wp-config.php file?

You can either limit or completely disable revisions by editing the wp-config.php file.

The wp-config.php file is located in your domain's primary folder. See this article to learn more about how to log in to your server using an SFTP client to access this file.

Limiting revisions

If you want to reduce the number of revisions saved, add this line to your wp-config.php file after the database info:

define('WP_POST_REVISIONS', 3); // Number of revisions to save.
define('AUTOSAVE_INTERVAL', 120 ); // Default value is 60 seconds.

The above code limits the number of revisions to 3 and changes the auto-save value to every 2 minutes. It is recommended that at least 3–5 revisions be saved, but you can change those values to something higher (or lower).

Disabling revisions

To prevent revisions from being created and stored in the first place, you can use the following code in place of the one above:

define('WP_POST_REVISIONS', false);

See also

This form is only for article feedback. If you require assistance, please contact support. Do not include passwords, account numbers, or other private account details.

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?