Manage and Remove WordPress Post Revisions

27
Dec

In a quest to keep the WPInsite MySQL database file size to as small as possible I have decided to manage and remove the WordPress post revisions from the database. This article will outlines ways in which you can manage and remove your WordPress Post Revisions.

Understanding WordPress Post Revisions

WordPress has built in feature that automatically saves versions or revisions of your posts as you edit and create them. Depending on who you speak to this option can be an advantage or a hinder. Post revisions are stored in your “wp_posts” table in your MySQL database.

Advantages of WordPress Post Revisions

Post Revisions are an advantage to any post editor in that by default every time you click the save or update button a copy or revision of that certain post is saved in the database. This handy feature allows you to go back to a certain post revision and restore that revision, thus taking the post content back to previous date in time.

Disadvantages of WordPress Post Reviews

There is a cost to having all these saved revisions of your posts in the aspect of database entries. Instead of having a single MySQL database record for your post you will have multiple records for each post therefore increasing the total amount of records and an increase to the total MySQL database. This might not sound like a big detail but just for the sake of an example say you have 10 post revisions per post and in your WordPress blog you have 500 posts or articles. This results to 5000 database records. This in total could slow down the overall page loading speed of your WordPress blog.

Enabling & Disabling WordPress Post Revisions

WordPress have a built in constant called WP_POST_REVISIONS that enabling you to change the settings of the post revisions. By using this function you are able to disable or enable the post revisions. There are a few options you have to utilizing this constant.

To totally disable the post revisions you can do this by adding a constant to you WordPress wp-settings.php file which is located in the root of your WordPress installation. WP_POST_REVISIONS are enabled by default.

1
define(’WP_POST_REVISIONS’, false );
define(’WP_POST_REVISIONS’, false );

You also the ability to set a maximum number of post revisions that you want to use for each post. You simply add an int to the constant call. Any previous post revisions will be deleted for that certain post.

1
define(’WP_POST_REVISIONS’, 3);
define(’WP_POST_REVISIONS’, 3);

The above code snippet will save a maximum of 3 revisions per post thus limiting the amount of rows created in the “wp_posts” database table.

Plugins Available to Manage Post Revisions

As with most WordPress tasks there are usually a number of plugins available for you to download from the WordPress Plugin Repository to help you to manage your post revisions. I will outline a few of these plugins that offer great functionality on managing your revisions and the amount of revisions.

Revision Control

Revision Control WordPress Plugin

Revision Control WordPress Plugin

Revision Control is a plugin for WordPress which gives the user more control over the Revision functionality.

The plugin allows the user to set a site-global setting (Settings -> Revisions) for pages/posts to enable/disable/limit the number of revisions which are saved for the page/post. The user may change this setting on a per-page/post basis from the Revisions Meta box.

The plugin also allows the deletion of specific revisions via the Revisions post metabox.

Download the WordPress Revision Control plugin

Bulk Delete

The Bulk Delete WordPress Plugin has great functionality

The Bulk Delete WordPress Plugin has great functionality

Bulk Delete is a WordPress Plugin which can be used to delete posts in bulk from selected categories, tags or custom taxonomies. This Plugin can also delete all drafts, post revisions or pages.

Download the WordPress Bulk Delete plugin

Revision Cleaner

Revision Cleaner plugin will clean up your revisions automatically

Revision Cleaner plugin will clean up your revisions automatically

This plugin will clean up your revisions AUTOMATICALLY (each authors can set their own interval). Once setup, ENJOY your writing.

Revision is a very useful stuff when you experienced an unexpected power failure or keyboard got peed by your cat while you’re writing an article or just simply revise what you’ve wrote. After you’ve “finally” posted your article, the revisions, still consuming your SQL database as long as the database last. To save your database storage, wipe out the revisions is necessary and this is what Revision Cleaner do in AUTOMATICALLY and safely (won’t delete any draft :) ). “Clean interval” setting support multiple-users, they can set their own clean interval (admin can control it and assimilated everyone of course).

Download the WordPress Revision Cleaner plugin

Revision Removal

Remove the WordPress post revisions from your database

Remove the WordPress post revisions from your database

Remove the revision posts from your database in order to reduce your database size and optimize the speed of your database load!

Revision Post is the new features of WordPress ver 2.6 and above. Every time you made a change to your post or page, it will automatic save add a revision, just like a draft. As many as you made change, the more revision you will have in your database. It will not only increase your database size, but also increase your load time as the server need more time to access the database.

Revision Manager is your choice to remove all the revisions quickly to help you to increase the speed of implementation of the SQL statement, and increase the speed of your server load.

Download the WordPress Revision Removal plugin

Post Revision Display

WordPress Post Revision history displayed at end of post.

WordPress Post Revision history displayed at end of post.

Displays post-publication revisions along with differences/changes from current revision on single post views.

Want a way to show an “audit trail” for blog posts? Possible uses:

  • For web publishers, to allow the freedom of updating stories without worrying about confusing or deceiving readers. Anyone can see the changes.
  • For academic/student use of blogs, so students can’t “sneak” posts around submission deadlines by futzing around with the publish date.

On single post views, this plugin will display a list of all post-publication revisions, showing revision times, authors, and links to view them. When viewing a previous revision, differences (“diffs”) between the previous and current revision will be shown.

Download the WordPress Post Revision Display plugin

WP-Optimize

WP Optimize WordPress plugin manages and deletes your post revsions

WP Optimize WordPress plugin manages and deletes your post revsions

This simple but effective plugin allows you to clean up your WordPress database and optimize it without phpMyAdmin. Also renames any username.

WP-Optimize is a WordPress 2.9++ database cleanup and optimization tool. It doesn’t require PhpMyAdmin to optimize your database tables. It allows you to remove post revisions, comments in the spam queue, un-approved comments within few clicks.

Additionally you can rename any username to another username too.

For example: If you want to rename default ‘admin’ username to ‘someothername’; just put ‘admin’ (without quotes) to the Old username field and the new username to the New username field, then click “PROCESS”)

Download the WordPress WP-Optimize plugin

Ways to manually delete and remove your Post Revisions

If you do not prefer to use a plugin to manage and delete your post revisions or for whatever reason you can manually delete and manage your post revisions from the wp-posts database table. The best way to achieve this task is to run an SQL database query through phpMyAdmin. This is quite an advanced topic so please be sure to BACKUP your database PRIOR to running any queries against your database.

To view how many post revisions are stored in your WordPress database run the following query.

The below query run against the WPInsite database

The below query run against the WPInsite database

1
2
3
4
SELECT * FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.id = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id )
WHERE wp_posts.post_type = 'revision' LIMIT 0 , 30
SELECT * FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.id = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id )
WHERE wp_posts.post_type = 'revision' LIMIT 0 , 30

As you can see the result of the above MySQL query returned 1,495 database rows or records. Having thousands of post, you can easily start to see how this could start to clutter your MySQL database. What this query does is checks the wp_posts database table as well as the relationships on the wp_term_relationships & wp_post_meta tables.

Change the query to delete the revisions

If you are certain that the result has only returned the records or rows you are after you can change the query to a DELETE statement to delete the post revisions.

At this stage I must point out that it is advisable to BACK-UP your WordPress database PRIOR to running any queries against it that will change the content or delete records from the database.

To permanently delete the post revisions run the following MySQL database query.

1
2
3
4
DELETE * FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.id = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id )
WHERE wp_posts.post_type = 'revision' LIMIT 0 , 30
DELETE * FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.id = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id )
WHERE wp_posts.post_type = 'revision' LIMIT 0 , 30

Conclusion

So there you have it. This articles has outlined several way for you to reduce the size of your WordPress MySQL database by learning how to manage and remove WordPress Post Revisions.

Be sure to check out our other great WordPress Articles and Plugins
Enjoy this article? If so, we would love to hear your thoughts in the comments below

 

Related Blog Posts

One Response to Manage and Remove WordPress Post Revisions

  1. This plugin is safe and will not error

    Reply

Leave a Reply