Post Revision Feature in WordPress is very useful in case of a blog with multiple authors/editors. It’s similar to a version control system which tracks the history of changes of your posts/pages on: Who did the change?, When did they change? and What did they change? Therefore, you can review each of saved version and also revert back to a previous version. It means your published contents are always safe and never be overwrite, you can re use them whenever you want.
However, as you know, the revisions are stored in the posts table as children of their associated post and will be auto inserted into the database whenever update your article, even it’s just a minor change. Your database will be grown significantly with lot of revision records creating and definitely reduce the performance, waste resources and increase page loading.
Deleting or removing the Post Revisions is a good idea to increase the web page serving, optimize the performance, reduce the database size, speed up the backup process as well as download/transfer the backup file 🙂
To delete the existing Post Revisions, simple run SQL command below in your PhpMyAdmin or SSH:
[text] delete from wp_posts WHERE post_type = ‘revision’;[/text]
After that, you may need to delete all its related relationships (in wp_term_relationships table) as well as its meta data (wp_postmeta table):
[text] delete from wp_postmeta where post_id not in (select ID from wp_posts);delete from wp_term_relationships where object_id not in (select ID from wp_posts);
[/text]
Note:
- 1. Replace ‘wp_’ with your current table_prefix
- 2. After delete the Revisions, you can not check the change history or revert your article by an older version so please ensure you understand what you’re deleting. Backup your database and just delete the Revisions in a period of time is a good idea, I think 🙂
Bonus: in order to completely disable the Post Revision Feature, you can add the code below somewhere in your wp-config.php file, it will turn off the feature and will not store any revision post.
[text] define(‘WP_POST_REVISIONS’, false);[/text]