Why You Should Disable Wordpress “Post Revisions” To Save Database Space

Wordpress has a function titled “Post Revisions” that when each time you save draft or publish a post or page and saves a revision copy of that post or page. It was introduced to help wordpress bloggers to keep revisions of post and restore to previous revisions anytime. This Feature can take up a huge chunk of database space however if you have a site that has a lot of articles, in this post we will show you several methods of how to disable the “Post Revisions” Feature and deleted stored revision posts from your database.

So whats the main benefit when disabling “Post Revisions” within wordpress?. Here at SocialCMSBuzz we had a database size of around 28MB, after disabling and deleting our “Post Revisions” this number dropped to around 8MB thats 20MB of a saving in MYSQL space within your wordpress database.

Method One – Getting Hands Dirty

The first method we will show you requires you to edit the wp-config.php to disable “Post Revisions” and also run an SQL query from within phpmyadmin to delete any stored “revision” posts from your wordpress database. There are several options we can use when disabling post revisions, read more about them here Revision Management.

To simply disable Wordpress posts revisions completely we have to edit the wp-config.php file found in you wordpress root directory.

Copy and Paste the code below into your wp-config file, this will disable post revisions.

1
define('WP_POST_REVISIONS', false);

Next we need to run an SQL query from within PhpMyAdmin to delete the “Post Revisions” from your database. Remember to backup your database first as you always should before running any queries.

Run this query below

1
DELETE FROM wp_posts WHERE post_type = "revision";

Another query you could try is an older one from Lester Chan which deletes “Post Revision” data from wp_postmeta and wp_term_relationships tables also.

1
2
3
4
5
DELETE a,b,c  
FROM wp_posts a  
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)  
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)  
WHERE a.post_type = 'revision'

Method Two – Use A Plugin

There are also a few plugins available to preform this task if you wish to use these we have listed them below for you.

Wordpress Revision Control Plugin

revision-control-1

Revision Control is a plugin for WordPress 2.8+ which gives the user more control over the Post/Page Revisions.

The plugin allows the user to set a blog-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.

Wordpress Delete Revision Plugin

delete-revision-plugin

Let us know if you use any of these methods, how you get on and if you saved any database size.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Article Details

#

Author: Lincoln on November 25th, 2009

Category: Wordpress, Wordpress Hacks

Tags: ,

  1. Heather says:

    I installed the plugin on one of my sites but found that it only affects revisions going forward from the time you installed it – it does not remove existing revisions. So, I ran the SQL query as well. As a result, its database size went from 983 KB to 60kb in less than a minute. How. Cool. Is. That.

  2. Lincoln says:

    Hi Heather,

    Did you install both plugins? the first Wordpress Revision Control Plugin allows you to control the revision options and the second Wordpress Delete Revision Plugin should allow you to delete them.

    Let me know if you tried the Wordpress Delete Revision Plugin and if it was that plugin that didn’t work. If so i will edit the article to reflect this.

    Thanks and happy this help you save some space :)

    Lincoln

  3. Kenneth says:

    Hi, is their a way to change of often the “Post Revisions” saves a revision? Like every fifth minute or so?

  4. Techachino says:

    Thanks for the information. But it would be helpful if you would reverse the order of the SQL queries listed in your post. Running the second one after you already deleted all revision posts is useless.

  5. paul says:

    great info. thanks for sharing.

  6. THANK YOU for this. I had close to 700 redundant posts hanging out there on just my small blog yeesh!If going to mention this on my blog as well (props back to you of course)

  7. Why does the Codex article you linked to (Revision_Management) state exactly the opposite of what you said… verbatim:

    “There is only ever a maximum of one autosave for any given post. New autosaves overwrite old autosaves. This means that no, your tables do not grow by one row every 60 seconds.”

    I keep reading all these panic articles about disabling your autosaves… and while it seems like it may have been necessary in v2.6 when this features was released… it certainly isn’t anything to worry about now @ v2.9

    Even though the list of revisions looks long, it’s only ONE save to the table… so basically, everytime you write a blog post, it’s only saving a second backup post as a reference for ALL those revision.

    It’s not that big of a deal… people in the computer world actually go as far as to RAID their hard drives together, just to create a redundancy in case of disaster… it’s. a. good. thing!

    And as far as I can tell, Wordpress has implmented the feature in a very clean manner that does exactly the OPPOSITE of what your telling the world here.

    You should really READ the articles you quote.

  8. thanks for teach us how to disable post revisons function, I need that function.

  1. Scrap Wordpress “Post Revisions”? | BloggerTools.Net

Leave a Reply