WordPress: Delete post revisions to speed up your blog

Post revisions can be very useful for keeping track of multiple version of an article. However, this means additional burden on the database as the number of database records increases manifold.

If you are like me, each article or blog post will be revised 5-10 times for correcting errors. A WordPress blog with 100 articles, which have 10 revisions each, will end up with 1,000 records in the wp_posts tables of the WordPress database. The WordPress blog would have functioned more efficiently with only 100 entries and no post revisions.

If your WordPress website has hundreds of posts, it is better to disable WordPress post revisions. You should also get rid of posts revisions to significantly lower the number of records in the database.

Run the following MySQL query to delete all post revisions as well as all associated meta data such as custom fields. It will reduce the size of the database and speed up the website.

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

Once again, back-up your database before tinkering with it. If you damage your database during the process, you can revert to original version. Not doing so means you risk losing the website.