How to save a lot of database space by turning off and deleting revisions in WordPress

A serious blogger edits and rewrites his post vigorously. By default, WordPress saves all this revisions, consuming a lot of space. You can see revisions when opening posts in dashboard. Every revision is like another post in terms of space, and if you have only one post with 70 revisions, that actually means you have 71 post saved in your database.
If your database space is limited, here’s how you can save the day.


First, turn off revisions saving by changing or adding the following code to wp-config.php:

define('WP_POST_REVISIONS', false);

This will prevent WordPress from saving revisions in the future.
Now we have to remove those already stored in the database. You may use a plugin for that or purge them directly through SQL. To do that, launch any SQL tool you have, myadminPHP being the most commonly available one, copy-paste and execute the following code in SQL window:

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’re done. No space wasted anymore.

Learn how to remove W3 Total Cache errors.

Leave a Comment