If you write your posts in a busy family environment as I do, you learn to hate WordPress post revisions. Despite WordPress’s built in autosave feature, I like to save often, walk away, scream at the kids and then return to my writing. By the time I’m finally satisfied with a post I’ve accumulated 20 revisions, thus creating a huge database clutter. In my case I deleted almost 700 old post revisions following these instructions. Let’s learn how.
The first step is to stop any new revisions from being created. One method is to edit your wp-config.php file and add a line of code that says define(’WP_POST_REVISIONS’, false);The second method is to install a plugin called No Revisions. It performs as advertised. “Disables post revisions in WordPress 2.6 and on. Activate the plugin to disable them. Deactivate the plugin to re-enable them. Note that this does not delete any existing revisions, just stops WordPress from making any more.”
Fantastic! But how to delete those previous post revisions? First thing to do is backup your current database “just in case”. You should be doing this at least monthly on your own. It prevents any tearful “my cat jumped on the keyboard and screwed up my database” excuses during the process.
1. Log into your shared hosting account, Bluehost Hosting in my case. Under the “Database Section” click on the phpMyAdmin icon as illustrated. 
2. The phpMYAdmin control panel should open in a separate window. In the left sidebar you will see a list of databases, one for each WordPress installation. Click on the name of the database that has revisions you want to delete.
3. Then click the SQL tab for that database as shown.
4. Inside the box that says “Run SQL query/queries on database” paste the following text and then click the “GO” button. DELETE FROM wp_posts WHERE post_type = "revision";If you changed your WordPress database prefix, you must edit that line of code where it says “wp_posts”, but most installs use the default. A popup will ask if you really want to delete the revisions. Click yes if you are confident of your copy and paste skills.
5. phpMyAdmin will respond with a message. If it says “Error, table not found”, check your prefix. If it says “Deleted rows: 0 (Query took 0.0007 sec)” then you already had revisions turned off. If you are successful it will say something like “Deleted rows: 8 (Query took 0.0007 sec)”
6. While you are there, spend an extra 10 seconds and follow my directions to Optimize Your MySQL Database Tables and make your site run faster.
This procedure deleted almost 700 old post revisions from Turnipofpower.com’s database. Some of you may say “who cares”? But if you ever had to upload a backup copy of a huge database, then you may understand. Shouldn’t WordPress automatically delete revisions after a certain date?
Great tutorial!
“Shouldn’t WordPress automatically delete revisions after a certain date?”
It would be a nice feature to have built in, that’s for sure.
Thanks for the detailed instructions on how to clean up this mess, Turnip. I end up with hundreds and hundreds of these as well.
I read the support forums a while back, looking for any sign of revision control getting into the core. Apparently, disabling revisions wasn’t important enough to go into the core. (I believe this was based on the thoughts of the developer team, rather than the community.)
They suggest using a plugin to disable revisions. Why were revisions important enough to go into the core but disabling them was not considered to be necessary? Why not do revisions as a plugin for those who want it?
I like WordPress as a system, but isn’t it a bit daft to have a “by developers, for developers” attitude while pushing the system as a “do everything for everyone” product? You can’t have it both ways.
Another great tip, thanks for sharing.
Hey , I finally decided to write a comment on your blog . I just wanted to say good job . I really enjoy reading your posts
For quite a while now numerous people have actually requested WordPress to add the functionality you mentioned here. Nothing so far, maybe in 2.8, who knows. The most important part of your advice is the bit about the backups. One does not mess around with SQL queries without taking the necessary precautions.
I like Ben’s suggestion that the entire revision thing be removed from the core. If anyone wants this functionality they can use a plugin. Things are the wrong way around right now.
Lyndi: I hate having to install a plugin for every minor option that seems to be common sense. I also don’t like changing core files if they get rewritten every upgrade. I never desired revisions to begin with. What WordPress needs to do is look at the most popular plugins and use that as a guideline for future changes. Maybe there’s already a plugin with the ability to toggle all the most common admin changes built in?
I don’t understand something, the revisions listing is at the very bottom of the page. Why is everyone so up in arms about it anyway? I barely even notice its there?
Am I missing something? Does it slow down my post editing? If it does I don’t notice it… I don’t know. It doesn’t seem like that big of deal *to me* to have it there.
Having said that, I still appreciate knowing how to turn it off without a plugin. Thanks Turnip.
Fragile: The revisions sit on a giant fluffy cloud. When there are too many revisions, the cloud sinks in the sky. When that cloud sinks, it rains. Pretty cut and dry if you ask me.
I guess I just don’t scroll down that far on my post editing screen. I never see it unless I accidentally scroll to the bottom.
It’s not about seeing it on the bottom of the screen. It’s about having 700 useless database items accumulated in over 6 months. Like having an operating system that never emptied it’s old temp files, there is no good reason to have a bloated database of old junk.
Ah, so I was missing something! I never look at it with the back-end in mind. Cool, I’ll actually consider doing this now
Great tip in removing excess from your host storage. I have implemented this a while back by adding a line of code to my wp-config.
Even 700 revisions is small potatoes when you’re talking about databases. I once admined a vb that had 3 MILLION posts. Now you’re talking some serious grunting. I haven’t looked, but are these revs COMPLETE copies of the posting or only diffs? If complete, they would build up quickly, if diffs, not so much. It could become a problem in a multiblog database such as mine. I only have six blogs in there and only two of them get posted to regularly, but if you’re runnin a wpmu setup the buildup could seriously cruft you. I would prefer to have a script that runs automatically as a cron say once a month or so. It would delete all revs except the last two, and/or just delete all revs older than a month. Also the table name isn’t always prefixed by wp_
If you did this cron thing, you’d have no plugin, no going in and futzing with the db yourself, a couple of revs of padding, and still keep your database sane. What am I offered to write this? It doesn’t have to be money.
Dorkage: Thanks for the offer, but I have already turned off revisions. I;m sure someone in the community would be nterested in your plugin though. I don’t even like the single revision WordPress forces on me. I save my work every few minutes. It’s the constant warning WordPress pops up saying “there is a more recent revison” when I go to edit an old post that bothers me most.
I really dislike the page revisions in WordPress as well. Don’t like to have plugins for something this small, so hard coding it was the route that I took.
Probably best to keep bulk stuff like this out of the database to avoid issues. The bigger they get the more possibility it could affect the loading speed of your site.