Delete post revisions in WordPress

ADVERTISEMENT
To get our software and web/tips via email, sign up for daily email newsletter.
Subscribe to RSS feed or follow me on Twitter?

WordPress introduced post revisions in v2.6. It has been useful for multi-author blogs (and individual bloggers who revise posts several times before publishing), as they can compare revisions of their post and choose from them for publishing. For most, however, this feature does not help much. In fact, I wouldn’t be surprised if you didn’t notice such a feature at all.

The unfortunate side effect of post revisions is that it bloats the database. For each edit / revision of a post, a new row is made in wp_posts table in your blog’s MySQL database. For blogs with daily (or more frequent) posts, post revisions can increase the size of your DB greatly.

Look at the screenshot of results after I deleted post revisions on this blog below. Note that I delete post revisions frequently, else the number of rows deleted would have been greater. You can imagine how large it will be for blogs which have never had their post revisions deleted.

Delete post revisions WordPress blogs database

Remove WordPress database post revisions

ADVERTISEMENT

How to remove post revisions in WordPress database

Thanks to the power of MySQL, you can remove all post revisions with a single command. Login to phpMyAdmin(or similar) and click to get into your WordPress database. Then click SQL tab, and paste the code below to the SQL command box:

DELETE FROM wp_posts WHERE post_type = "revision";

This should remove all post revisions. As with any other database manipulation commands, make sure to back up your database before running it.

To get our latest articles, click here to sign up for our free email newsletter or subscribe to RSS feed

§ Comments
  • Montana Flynn says:

    Didn’t work for me. :(

    Error
    SQL query:

    DELETE FROM wp_posts WHERE post_type = “revision”

    MySQL said:

    #1054 – Unknown column ‘“revisionâ€