You know i’m all for “If you can do it yourself then don’t use a plugin”. That goes, without saying, to my plugins too. So, i saw a plugin recently doing a very useful thing, cleaning up post revisions. But what is a post revision? Well, it’s a safety measure the WordPress team took since version 2.6.X to protect your writing from unfortunate circumstances that may occur. Moreover, it’s a way to have different versions of your posts. When you write you tend to delete and start over. At some point you might want to go back and see what your post looked like back then. Pretty much this is what post revision is.
But, when you are done with a post, you most probably will not use that ever again. So, think about having ten versions of a certain post, or even worse, ten versions of many posts. That’s a lot of unnecessary info and clutter for your database. To give you the whole picture, post revisions rest in the table that your actual published posts are. This is bad in two ways. One, it’s making it harder to index and make a query on the table. Even worse, when a query joins this table with another one then the result of the join will have a lot of junk lines, therefore, alot of no needed info. Two, imagine a post replicated ten times on your database. It could be like 60Kb or even, much more. Now that is alot of fragmented space. For this reason it’s a very good idea to remove post revisions.
The plugin can do the job for you but, as i already said, this is a trivial job and you can easily do it by hand. All you need to do is run a simple SQL query on your database and you will be done. Before going any further please make sure you keep a backup of your database for the scary moment that something goes wrong. Open your sql manager (either console or phpmyadmin or whatever you use to access your database). Run this query:
You are done! Please make sure you type exactly this and nothing less or you might be in serious trouble. Now, just to improve things for you, you might want to delete all revisions that are older than a month. This is what you are looking for:
This deletes all revisions that are older than a week today. So, go ahead and get rid of all the clutter. When i did so, i reduced my database’s size by 1.2Mb! I know, impressive huh? Keep one thing in mind though, backups, backups and more backups. The more the better 😉