Optimize WordPress Database by Disabling and Removing Revisions
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:
1 | define('WP_POST_REVISIONS', false ); |
Additionally, you might also want to increase the autosave time interval:
1 | define('AUTOSAVE_INTERVAL', 300 ); // seconds |
To delete all revisions that are stored in your database, simply execute this SQL query in your command line:
1 | DELETE FROM wp_posts WHERE post_type = "revision" |
Make sure to change the wp_ prefix with your database prefix.
Do you need help with a project? or have a new project in mind that you need help with?
Contact Me