Delete WordPress post revisions, turn them off and speed up your WordPress blog. Everytime you write or edit a WordPress post, WordPress saves the change as a post revision. As you might expect, this fills up your database with a huge amount of unneeded post revisions and information. This uses space which should be free space, the MySQL database becomes bloated. You can clean up these WordPress post revisions quite easily, you only need one SQL statement: …

Remove WordPress post revisions with an SQL statement

Clean up WordPress post revisions, save on MySQL database size and improve WordPress’ performance.

To delete the WordPress post revisions you only need one SQL statement. Execute this SQL query to remove all post revisions from your MySQL database:

DELETE a, b, c
FROM `wp_posts` a
LEFT JOIN `wp_term_relationships` b ON = b.object_id
LEFT JOIN `wp_postmeta` c ON = c.post_id
LEFT JOIN `wp_term_taxonomy` d ON b.term_taxonomy_id = d.term_taxonomy_id
WHERE a.post_type = "revision"
AND d.taxonomy != "link_category";
DELETE from `wp_posts` WHERE post_type="revision";

This’ll remove all WordPress post revisions, your MySQL database is smaller and faster! Don’t forget to change wp_ with your database table prefix.

Limit or disable WordPress post revisions

The maximum number of saved revisions can be configured in the wp-config.php file. To save a maximum of five revisions, use:

define('WP_POST_REVISIONS', 5);

Or to completely disable the WordPress post revision functionality, use:

define('WP_POST_REVISIONS', false);

However, according to Mike Little (the co-founder of WordPress), WordPress’ database queries do not retrieve revisions. The number of revisions should have no effect on the queries. The only time the revisions are retrieved is on the edit page of the individual post. There is no impact on the front end speed of your site.

The post revision feature can be a lifesaver. Share your opinion by commenting below.

Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link:


WordPress optimaliseren - · 30 December 2018 at 11:44

[…] Je verwijdert berichtrevisies (post revisions) eenvoudig, zoals uitgelegd staat in het artikel clean up WordPress post revisions. […]

Optimize WordPress MySQL tables through Cron, behind the scenes - Sysadmins of the North · 23 July 2018 at 10:39

[…] Speaking of post revisions, did you know you can easily delete old WordPress post revisions? […]

Leave a Reply

Your email address will not be published. Required fields are marked *

19 queries, 0.135 seconds running PHP version 7.3.2