Disable Post Revisions in WordPress to Reduce Database Size

WP 2.6 introduced a post revisions feature, which automatically saves a draft as you begin to write a post or page and saves a revision for each change made afterwards. That’s right, every time you make even the slightest alteration to a post or page, a new revision is saved. This may be useful feature (I doubt it) if you accidentally cut half of your post during a late night edit or lose power while composing your latest masterpiece, but these revisions can slowly build up in your database – especially if you edit your posts often.

By reducing the database size, you speed up your site as the database query lead to less results that need to be scanned.

define('AUTOSAVE_INTERVAL', 10000 );
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 10000 seconds, so it means your post will not be autosaved, you could make it even higher.

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 in any of the “Run SQL query” fields.

DELETE FROM wp_posts WHERE post_type = "revision";

This should disable Post revisions and delete all previously saved post revisions stored in your Database.
The earlier you do this, the less stuff you do not need is in the database.

Leave a Comment

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

You must tick the checkbox for 'I am not a robot' before you can submit your comment!