
Clean up your Wordpress posts
When you write posts on Wordpress, lots of revisions are saved and these revisions aren’t removed from the database, which means your database grows in size, which isn’t ideal when it starts getting rather big, this will only result in your website taking longer to load.
Here’s a great query you can run on your Wordpress blog, which will automatically remove all unwanted revision versions of posts:
DELETE a,b,c
FROM wp_posts a
WHERE a.post_type = ‘revision’
LEFT JOIN wp_term_relationships b
ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id);
Pretty neato trick, thanks go to WpRecipes.
PS. Please backup before just running this query!
Sharing is caring:
Tweet
Tweet
About the author:
Christopher is the founder of iMod - Most of his time is spent building websites and pushing the limits with Search Engine Optimization. You can follow him on Twitter @ChristopherM
Chris M has written: 4759 posts.
Christopher is the founder of iMod - Most of his time is spent building websites and pushing the limits with Search Engine Optimization. You can follow him on Twitter @ChristopherM
Chris M has written: 4759 posts.



































Mar 11th, 2010 at 8:06 am
You can also use something like http://www.ruhanirabin.com/wp-optimize/ which is what I use on my blogs. It’s better if you are not too keen on getting into the backend of things.
Mar 11th, 2010 at 10:49 am
Ah, nice one Darryl; I must admit, for most people, performing a SQL query is above and beyond their knowledge, so having a problem is far easier, thanks for sharing!
Mar 11th, 2010 at 12:44 pm
Love handy tips like these, thanks! Will give it a try. If I delete any important stuff, I’ll get Louise to contact you. Directly :0
Mar 11th, 2010 at 12:55 pm
Oooooooh no you won’t Elzet; haha! As mentioned, backup EVERYTHING before playing around :D
Mar 25th, 2010 at 11:20 am
I am using WP-CMS Post Control ( http://wordpress.org/extend/plugins/wp-cms-post-control/ )to stop revisions on pages and posts but hadn’t found anything to get rid of existing revisions. Thanks to @Darryl for the lead to WP-Optimize ( http://wordpress.org/extend/plugins/wp-optimize/ ) this has just saved me 3782.504 Kb of revisions space in my database from my 81 posts so far.