WordPress – Batch Delete Post Revisions

Post revisions, a new WordPress 2.6 feature, can be very useful, but they also increase the size of your MySQL database. Sure, you can manually delete posts revisions, but that’s very long and boring work.

The solution to this problem is simple: we batch delete post revisions by using a simple SQL query. The result can be almost unbelievable if you have a lot of posts: Your database size will be reduced by half!

1. Log in to phpMyAdmin and select your WordPress database.
2. Click the “SQL” button. Paste the following code in the SQL command window:

DELETE FROM wp_posts WHERE post_type = 'revision';

3. You’re done. Depending on how many posts you had in your WordPress database, you may have saved lots of precious space!

The wp_posts table has a field named post_type. This field can have one of many values, such as “post,” “page” or “revision.” When we want to get rid of post revisions, we simply run a command to delete any entry in the wp_posts table in which the post_type field is equal to “revision.”

Leave a Reply

Your email address will not be published. Required fields are marked *