Remove WordPress Revisions

WordPress Posts Revisions are useful especially in the case of a multi author blog. However, There is a cost to having all these saved revisions of your posts in the aspect of database entries. Instead of having a single MySQL database record for your post you will have multiple records for each post therefore increasing the total amount of records and an increase to the total MySQL database.This in total could slow down the overall page loading speed of your WordPress blog.

The best way to remove WordPress Revisions is to run an SQL database query through phpMyAdmin. This is quite an advanced topic so please be sure to BACKUP your database PRIOR to running any queries against your database.

Step 1: Backup your database
Step 2: Log into your phpMyAdmin panel
Step 3: Choose the WordPress Database from the left sidebar
Step 4: Click on the SQL tab which should bring you to a page with the SQL query box

To view how many post revisions are stored in your WordPress database run the following query.

SELECT * FROM wp_posts LEFT JOIN wp_term_relationships ON ( wp_posts.id = wp_term_relationships.object_id ) LEFT JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE wp_posts.post_type = 'revision';

What this query does is checks the wp_posts database table as well as the relationships on the wp_term_relationships & wp_post_meta tables.

Remove WordPress Revisions
The code bellow will delete all the post revisions and all the data associated with the post revisions.

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'

 

%d bloggers like this: