For users who had disabled or turned off post revisions tracking or versions history feature in WordPress (added since WordPress 2.6), it is also made sense to delete and remove all existing stored post revisions and changes made on pages stored in the database in order to reduce the wp_posts table size, especially when there is already tons of revisions or changes been kept.

To delete and remove all existing post revisions entries and rows from WordPress database Posts table, simply login to MySQL command-line interface, phpMyAdmin, SQLyog or other MySQL GUI tools. Select the appropriate WordPress database (if you have more than one databases on the same server), and then issue the following command (it’s also recommended to backup the database before performing the deletion SQL statements):

DELETE FROM wp_posts WHERE post_type = "revision";

Once all post revisions related records is purged, all revision histories is deleted, and users no longer able to check the changes by phase or compare differences between versions. Thus, deletion may also been used by administrator to ensure privacy or stop authors or writers in the blog from knowing their posts have been edited.

Related Posts

  • If this code doesn’t work for you, edit wp-config.php and do a search for $table_prefix. If the value of the table prefix is “example_” then update your code to make it look like this -> DELETE FROM example_posts WHERE post_type = “revision”;

  • Sau Hi

    Thanks for your great post, I deleted 4200 rows in database!

  • KucukMucit

    I’ve deleted 20630 records :) Thanks.

  • Auto

    I have tried some code in wp-config.php but auto saving drafts for posts/pages still remain. Please advice code that really works for WP 3.+

    Thanks!

  • hkmcgogo

    how to delete media record in wp_posts?

  • Hoan Huynh

    Thanks for sharing.
    BTW, do we need to delete its relationships as well as meta data.

  • Dan Sydnes

    Wouldn't this leave orphaned rows in the postmeta table?

  • Tom Turner

    Thanks for posting the query. It worked perfectly. Regards, Tom

  • lubos

    Awesome, thanks! Removed 3600 rows from my table…

  • Fanatic

    I just wanted to say a big thank you given I'm not a pro at the MySQL db management but your manual workaround to get rid of the revisions worked like a charm, I now also got the wp-config setup to disable the revisions.

    Thank you for sharing this information.

  • Wonkie

    Thanks – my backup database file was getting rejected by my email provider because of size… clearing out the old revisions helped tremendously!

  • Galerio

    Who is not familiar with SQL shell (to use the code suggested by Chlankboot) can safely use a plugin that does that work for you: Better Delete Revision.

    It is really better the "Delete Revision" plugin mentioned in this article because it not only removes old revision of posts and pages but also every other meta content related to those revisions!

  • FernandoJS

    Thanks for you business…

    I deleted 3400 registers in my blog.

    Regards

  • Window Replacement,

    I cannot for the life of me understand why all these revisions are automatically stored in MySQL. I mean, come on! Is this really a feature? Really?

    Thanks for the quick fix

    Karl A. Krogmann

  • vx

    Thank u bro

  • Thank you! Thanks to Ewen to for his wp_config entry "define(’WP_POST_REVISIONS’,6);".

    Cheers

  • I just tried this and it worked, great. Thank you. I have so many revisions it gives me a headache to look at the list on the page. And then to know that my database is storing all of that.

    I'm on Bluehost and at first couldn't figure out where to place the command script line. So I had to experiment and here's what I did:

    On my database page, the 2nd tab is called "SQL'. There is a field there called "Run SQL query/queries on database". You paste the line of code in there, click "GO" and presto.

    You get to start all over with the new revisions.

  • Thanks for this, dead simple, but dead useful!

  • Pingback: How to delete WordPress post revisions | Geekality()

  • Nice post, but u can use the plugin Revision Delete! for this problem :) . This wp plugin delete automatic all old revisions in db than older as x days.

  • Here's an easier way – add

    define('WP_POST_REVISIONS',6);

    to your wp-config.php file. change the 6 to however many revisions you want or -1 to keep them all. WordPress will delete the surplus revisions next time you save the post / page.
    http://codex.wordpress.org/Revision_Management

  • ¡Muchas gracias! Fue de gran ayuda.

    Thank you soo much! It was helpful.

  • Can`t for te life of me get DELETE FROM wp_posts WHERE post_type = “revision”; to work.

  • thanks man i need it :)

  • Great Guide!!!

    Seriously, I have one blog that is over 2 years old, that blog has seen more than it's fair share of revisions and updates, thus the revision history was pretty clogged up. I turned this feature off, but didn't know how to delete the history, which mean't the mysql database was horrible!

    I only noticed as I forgot my password recently (ooops!) and had to pop into phpmyadmin to reset it, whilst there, well, lets just say I am going to print off your instructions, and clear the mess up a bit! – Nice one, thanks so much for the tips!!!

    JOhn.

  • Excellent! Thank you for this and your tip to disable the WordPress revision feature entirely.

  • thats good info

    thx

  • Pingback: Eliminar los post del histórico en WordPress (Post Revision) | LeegaR Blog()

  • Pingback: Disable Wordpress Post Revisions « HCW()

  • Salut,

    Ce n'est pas suffisant, il y a deux autres tables affectees par l'autosave (wp_term_relationships et wp_postmeta), le code complet serait:

    <code>

    delete x,y,z

    from wp_posts x

    left join wp_term_relationships y on (x.id = y.object_id)

    left join wp_postmeta z on (x.id = z.post_id)

    where x.post_type = 'revision'

    </code>

  • Great tip!

  • I don't need the post revision feature either, as I'm the only author of my blog. Thanks for this tip.

  • Great tip!

    The revisions take up a huge amount of space when editing posts.

    I installed a new skin and had to edit each post to match….. twice the database size :(

    Thanks for this tip, very useful!

  • Pingback: Schusterjunge» Blogarchiv » Update auf WP 2.6.1()

  • Pingback: WordPress and how to disable post revisions - Forty Plus Two()

  • Pingback: Delete Wordpress 2.6 Revisions | Andrei Neculau()

  • Pingback: Disable Wordpress Post Revisions | WeiPAD()