Fine tuning WordPress revisions


Post Revisions is a WordPress feature that has proven to be helpful as the revisions system stores a record of each saved draft or published update. While these are very nice to have, some databases can balloon if you're prone to making a lot of changes or spending a lot of time creating a post. To help keep your database size down — which keeps your install speedy — you might want to fine-tune the number of revisions your site saves.

Running a MySQL query

If you don't want to add another plugin to your WordPress installation, then you can run a simple SQL query to remove revisions.

To set up a SQL query:

  1. Open your panel and navigate to the MySQL Databases page.
  2. Log in to phpMyAdmin. You will see your tables listed on the left.
  3. Click your database name.
  4. Make a note of the table prefix.

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

  5. At the bottom of phpMyAdmin, click the Console icon to open the SQL command window.
    The SQL command page opens:
    Wp finetune3.fw.png
  6. Paste the following SQL command in the SQL window:
    DELETE FROM wp_posts WHERE post_type = "revision";
  7. To run the command, click CTRL + ENTER.

This will remove all revisions currently stored in the database. Just make sure to enter the correct table prefix into the query. In the example above, the prefix is just wp_.

Limiting and Disabling 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.

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

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);

You can find the wp-config.php file in your FTP account. It will be in the primary folder for your domain.

You can read more about revisions via the WordPress codex here:

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?