WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Disable Post Revisions in WordPress and Reduce Database Size

How to Disable Post Revisions in WordPress and Reduce Database Size

Last updated on June 21st, 2012 by Editorial Staff
21 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
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.

21 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

32 Comments

Leave a Reply
  1. Djomlatan says:
    Apr 1, 2020 at 6:09 pm

    Great article, simple and exactly what I needed.

    Reply
    • WPBeginner Support says:
      Apr 2, 2020 at 8:41 am

      Thank you, glad our guide was helpful :)

      Reply
  2. Capitallen says:
    Jul 16, 2019 at 8:31 am

    does it work with WP 4.9 and 5.1 or later?

    Reply
    • WPBeginner Support says:
      Jul 16, 2019 at 10:46 am

      Yes, this method should still work for those versions and later :)

      Reply
  3. George says:
    Nov 27, 2016 at 10:46 am

    Hi.
    If I put the following code:

    define(‘WP_POST_REVISIONS’, false);

    It’ll stop any further revisions,even page revisions?
    What the autosave does,occupies space in database?

    Thank you

    Reply
  4. Owais Akber says:
    Jun 18, 2016 at 10:09 am

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

    Reply
    • Distro says:
      Aug 19, 2016 at 12:35 am

      Its fine on my side using WordPress 4.5.3

      Reply
  5. yuki says:
    May 4, 2016 at 9:47 pm

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

    Reply
    • WPBeginner Support says:
      May 4, 2016 at 10:11 pm

      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.

      Reply
  6. Sandy Firmansyah says:
    Apr 9, 2016 at 4:15 am

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

    Reply
  7. David says:
    Apr 29, 2014 at 12:51 am

    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

    Reply
    • Lại Đình Cường says:
      Aug 21, 2014 at 7:19 pm

      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’));

      Reply
  8. orangorangan says:
    Mar 2, 2014 at 11:44 pm

    Hi, seems like doesnt work for WordPress 3.8 ?

    Reply
    • WPBeginner Support says:
      Mar 4, 2014 at 5:47 pm

      It works perfectly fine on WordPress 3.8

      Reply
  9. Sajna says:
    Oct 26, 2013 at 3:18 am

    Will it work for Wordperss 3.7?

    Reply
    • WPBeginner Support says:
      Oct 26, 2013 at 11:37 am

      Yes.

      Reply
  10. namaserajesh says:
    Nov 3, 2011 at 4:10 pm

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

    Reply
  11. axelchanfrault says:
    Jul 11, 2011 at 2:57 am

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

    Reply
  12. Boutros says:
    Jan 5, 2011 at 10:20 am

    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.
    Thanks,
    Boutros

    Reply
  13. will says:
    Nov 16, 2010 at 11:01 am

    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

    Reply
  14. Ashfame says:
    Aug 17, 2010 at 5:45 am

    Wrong method of deleting post revisions

    Reply
    • Editorial Staff says:
      Aug 17, 2010 at 1:39 pm

      You got a better method? then please share.

      Reply
      • Ashfame says:
        Aug 19, 2010 at 9:10 am

        Hey!
        Good to see you responding :)
        Here is the tutorial – http://blog.ashfame.com/2010/04/handling-wordpress-post-revisions-correctly/

        Reply
        • Adrian P. says:
          Sep 20, 2019 at 9:54 am

          I thought this is just too simple. Thanks for the heads up!

  15. Titifrim says:
    Apr 29, 2010 at 8:09 am

    Nice post but for my part I prefer to use this plugin http://wordpress.org/extend/plugins/wp-optimize/

    Reply
    • Adhie says:
      Apr 29, 2010 at 3:15 pm

      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…

      Reply
  16. Sidd says:
    Apr 2, 2010 at 1:47 am

    Thanks.
    Our database badly needed that !

    Reply
  17. Sunangel says:
    Mar 8, 2010 at 5:16 pm

    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!

    Reply
  18. Keith Davis says:
    Oct 10, 2009 at 3:13 am

    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.

    Reply
    • Editorial Staff says:
      Oct 10, 2009 at 4:17 am

      Glad you made your way here from Six Revisions. Yes, it is possible. Simply use this plugin.

      Reply
  19. Dan says:
    Sep 26, 2009 at 8:50 am

    You can also use something like http://wordpress.org/extend/plugins/revision-control/ if you want a bit more control over just turning off revisions altogether.

    Reply
    • Keith Davis says:
      Nov 9, 2009 at 2:51 pm

      @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?

      Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
SeedProd Logo
SeedProd
Create beautiful custom landing pages - Drag & drop builder. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2021 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2021)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2021)
    • SiteGround Reviews from 4464 Users & Our Experts (2021)
    • Bluehost Review from Real Users + Performance Stats (2021)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2021 – Step by Step Guide
Deals & Coupons (view all)
wpDataTables
wpDataTables Coupon
Get 20% OFF on wpDataTables WordPress plugin for tables and charts.
Smash Balloon Coupon
Smash Balloon Coupon
Get 50% off Smash Balloon's powerful social media feed plugins.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
  • Growth Fund
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon
  • AIOSEO

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress Security by Sucuri.