Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Disable Post Revisions in WordPress and Reduce Database Size

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Disable Post Revisions in WordPress and Reduce Database Size

Post revisions is a great feature that WordPress has to offer but for some users it might not be the best option. For users who have limited database space, or for users creating WordPress as a CMS where they don’t need autosave, they can simply disable Post Revisions feature in WordPress by following this tutorial. By reducing the database size, you can also speed up your site.

Open wp-config.php located in your WordPress root directory and add the following code:

define('AUTOSAVE_INTERVAL', 300 ); // seconds
define('WP_POST_REVISIONS', false );

This code will disable all future revisions to be saved and it will also increase your autosave interval from 60 seconds to 300 seconds, so it means your post will be autosaving every 5 minute instead of every minute.

The above code, will not delete your past revisions that are already saved in your database. To delete all previous revisions, you will need to visit PHPMyAdmin and run the following SQL query.

DELETE FROM wp_posts WHERE post_type = "revision";

This should disable Post revisions and delete all previously saved post revisions stored in your Database.

Disclaimer: We are not suggesting that Post Revisions is a bad option. This tutorial is only for those who are in the situation where they need to reduce their database size.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Owais Akber says:

    Tried with 4.5.2 and did not work, even i restart my xampp and tried after relogin, still getting revisions.

  2. yuki says:

    it doesn’t work with wp 4.51…. anybody can help? thanks!

    • WPBeginner Support says:

      We checked, it still works with WordPress 4.5.1. Please recheck the code you entered. Or may be this code does not do what you are trying to do.

  3. Sandy Firmansyah says:

    Awesome.. it’s work on latest wp.. thanks

  4. David says:

    Superb article — may be good to note that DELETE FROM wp_posts many not work if user changed table prefix (recommended) … and for user to change code to their table prefix :) thanks guys

    • Lại Đình Cường says:

      You’re right David. If you change the table prefix, you can try by using global $wpdb:

      $wpdb->query($wpdb->prepare(“DELETE FROM $wpdb->posts WHERE post_type = %s”, ‘revision’));

  5. orangorangan says:

    Hi, seems like doesnt work for WordPress 3.8 ?

  6. Sajna says:

    Will it work for Wordperss 3.7?

  7. namaserajesh says:

    Nice tips, instead of disabling revisions I’ll keep revision count 2 or 3. Thanks for this info. Great blog.

  8. axelchanfrault says:

    This is a very clever tip, I never thought of that. Thanks!

  9. Boutros says:

    About the SQL query you have in your post:

    DELETE FROM wp_posts WHERE post_type = “revision”;

    For me it only works with single quotes around the term revision and not double quotes. (I have MySQL server version 5.1.30). I thought I mention this for others.

  10. will says:

    really needed this one of my post had over 200 and i couldn’t figure out why. you guys are the best thanks a lot again

  11. Ashfame says:

    Wrong method of deleting post revisions

  12. Titifrim says:

    Nice post but for my part I prefer to use this plugin

    • Adhie says:

      Agreed with Titifrim. With wp-optimize, there is option to “remove all post revision”. Another option: Clean marked Spam comments, Clean Unapproved comments, and Optimize database tables…

  13. Sidd says:

    Our database badly needed that !

  14. Sunangel says:

    Deleted rows: 356 (Query took 0.0240 sec)

    Yes, it does clog up the database tremendously fast! I have just been building this site – mostly over the weekend.

    Thank you for this fix!

  15. Keith Davis says:

    Came to this site via Six Revisions, great site, great tutorials.
    Never thought that all those post revisions are saved in a database… the database must get bigger and bigger!
    Can post revisions be deleted via the Dashboard? Would be useful for people like me who are OK with html and CSS but shy away from PHP coding.

  16. Dan says:

    You can also use something like if you want a bit more control over just turning off revisions altogether.

    • Keith Davis says:

      @Dan… do you use this plugin yourself?
      I need something like this because the instructions… “run the following SQL query” to delete revisions, scares me to death.

      Will the plugin delete existing revisions?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.