Overview
This article provides instructions on how to adjust the amount of revisions your WordPress site saves.
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 to make adjustments
Depending on your preference, you can make revision adjustments in either phyMyAdmin or within the wp-config.php file for your WordPress site.
Using phpMyAdmin
If you do not wish 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 in phpMyAdmin:
- Open your panel and navigate to the MySQL Databases page.
- Log in to phpMyAdmin. Your tables appear on the left.
- Click your database name.
- 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_.
- At the bottom of phpMyAdmin, click the Console icon to open the SQL command window.
- The SQL command page opens:
- Paste the following SQL command in the console:
DELETE FROM wp_posts WHERE post_type = "revision";
- To run the command, click Ctrl + Enter, which 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_.
Editing 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);