Improving WordPress speed by cleaning revisions

What is a revision

Every time you save the changes on a post or a page WordPress keeps a revision of your content as a backup. This way you can easily revert any changes that may not look like you wanted them to. You can easily select an older version of your content and go back to it, just by selecting it.
But a long list of post revisions might slow your blog down and use more resources than normal, so here is how to delete, limit or disable the post revisions in WordPress.

Delete all revisions

The SQL source code bellow will delete all your post revisions and all the data associated with the post revisions. This is an SQL Query and you can run it via the PHPMyAdmin interface.
! BE SURE TO KEEP A BACKUP OF YOUR DATABASE BEFORE RUNNING IT !

DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'

Disable revisions

The code should be placed in the wp-config.php file located in the root folder of your WordPress installation. It will completely disable post revisions.

define('WP_POST_REVISIONS', 'false');

Limit the number of revisions

The code should be placed in the wp-config.php file located in the root folder of your WordPress installation. This will limit the number of revisions to 7. It won’t stop making revisions after the 7th one, it will simply delete the oldest automatically and create a new one.

define('WP_POST_REVISIONS', 7);

Written By

Panagiotis (pronounced Panayotis) is a passionate G(r)eek with experience in digital analytics projects and website implementation. Fan of clear and effective processes, automation of tasks and problem-solving technical hacks. Hands-on experience with projects ranging from small to enterprise-level companies, starting from the communication with the customers and ending with the transformation of business requirements to the final deliverable.