Optimize WordPress Database by Disabling and Removing Revisions

Date Posted: November 27, 2014, 9:59 am

After several edits on site postings, there may be several dozen copies of revisions and many of them are days or weeks old.

Now that we know that every one of these old versions is stored in the database we understand why it is growing exponentially in size making it all but impossible to manage, download, upload etc. While having all these copies is somewhat helpful during editing, once an article is published they are of little or no further use. Some or all need to be deleted for very practical reasons.

Best way to stop WordPress from saving revisions on database is to simply define this code into your config.php:

define('WP_POST_REVISIONS', false );

Additionally, you might also want to increase the autosave time interval:

define('AUTOSAVE_INTERVAL', 300 ); // seconds

To delete all revisions that are stored in your database, simply execute this SQL query in your command line:

DELETE FROM wp_posts WHERE post_type = "revision"

Make sure to change the wp_ prefix with your database prefix.

About author

Carl Victor Fontanos

A fine gentleman specializing in front-end and back-end development with extensive experience building high performance web applications that keeps users engaged and help businesses grow.

Hire Me