Delete Unused Post Revisions

Post revisions are a WordPress feature that allows you to undo changes and go back to an earlier version of your posts and pages, it works by auto-saving every 60s while you edit content.

Since revisions can take up a lot of space in the database, it is a good idea to delete them.

DELETE FROM wp_posts WHERE post_type = "revision";

or

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'

You can also limit the number of revisions WP keeps for every post/page by adding the following in wp-config.php file:

define( 'WP_POST_REVISIONS', 10 );

Replace 10 with the number of revisions you want to keep for each post.

Was this post helpful?

Leave a Comment