Turn Off Post Revisions from Wordpress 2.6
Here at devjargon, like most blogs around the blogosphere, we use Wordpress as our platform. We like the ease of development and the relatively fast performance that it gives us. We recently updated to the newest version of Wordpress 2.6, and so far have been fairly impressed with the new additions.
One thing that I don’t like about Wordpress 2.6 is post revisions. Today I’m going to show you how to turn post revisions off so your wordpress database doesn’t get bogged down with useless entries.
I’m not the best writer, I normally take my time and make a number of saves throughout a posts creation. With post revisions turned on, this means that for every save a new database entry is added to the wp_posts table. Now I realize that this really isn’t that big of a deal, but it adds up over time.
Lets say that you’re blog posts 4 times a week and on average saves each post 5 times (I save at least this many). That means that every week, your wp_posts table gets 24 new entries every week (5×4 for each revision and 4 for each final post). This means that your table will have 1248 new rows every year (at a minimum). This will add up with years of blogging and can possibly slow your blog down.
Remove Post Revision Functionality
To actually remove the post revision functionality so that it doesn’t save any revisions you’ll have to add a line to your wp-config.php file.
define('WP_POST_REVISIONS', false);
This will make sure that Wordpress doesn’t save any more revisions of your post.
Remove all revisions from your database
If you’ve already saved a few posts before turning off Post revision, and you want to clean up your Wordpress database you can do the following SQL query through phpmyadmin.
DELETE FROM wp_posts WHERE post_type = 'revision';
This will clean up your database and remove all unwanted revisions. Just make sure that you backup your database first (just in case).
This is really the only feature in Wordpress 2.6 that I don’t like. I love the new plugin functionality, the ability to preview your theme before you go live and pretty much everything else. I just feel that the people over at Wordpress should have given us the ability to turn of Post revisions if we wanted to.
5 comments
9:59 pm
Great advice. I don’t really care about this feature. I guess if you’re running a blog with multiple authors it may be good to have, or if your using Wordpress as a true CMS, but if your using it as a single author blog there really isn’t a point in having Post Revisions turned on.
9:19 am
You might also want to add:
define(’AUTOSAVE_INTERVAL’, 600000)
to turn off autosave. This also adds an extra row to the database when editing an existing post.
3:55 pm
Great tip!
Do you know whether any other tables should also be cleaned up?
For example, are there corresponding rows in wp_postmeta and wp_term_relationships that should also be deleted, so that wp_posts does not get “out of sync” with the other tables?
11:02 pm
Hey Bruce,
You don’t need to touch wp_postmeta, nothing about revisions is stored there.
As for wp_term_relationships, I’m not 100% sure but I think you’ll need to delete entries where the object_id is equal to the ID of each of the revisions.
delete from wp_term_relationships where object_id = {ID_of_Revision};
8:32 am
Thanks Adam. I will be applying this today.
Great tip!
Leave a Comment