This is actually’s first post ever regarding WordPress itself, which is the engine that powers this website.

This article is nothing new and is really going to benefit me the most, because deleting post revisions is something that is done every couple of weeks here. Now I will have a permanent record of this SQL statement.

When searching Google for this query, you will see a simple version that you should not use. This one-liner below will delete revisions, but leave behind any meta data in your database. Always backup your blog database first.

Deleting Old Post Revisions

Avoid this commonly seen query.

MYSQLview code
DELETE FROM wp_posts WHERE post_type = "revision";

Here is a better query to delete all post revisions.

MYSQLview code
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'

Disabling Post Revisions

If you also want to disable the post revision system, you can add this commonly blogged about line near the bottom of your wp_config.php file.

define('WP_POST_REVISIONS', false);