Save more WordPress’ database disk space with a simple trick

If you use WordPress as blogging platform, and you have installed a recent version, you must have see that it has become more greedy in space.

This is particularly due to the registration of “revisions”.

What is “revisions”?
These are versions of posts that are recorded as you write. This is a very useful feature when writing a post several times, not to lose content that might have cleared.

However this feature is greedy and take a huge disk space on the database because each revision takes roughly as much space as the post finally published.

Personally I use the revisions until the final publication. But after this stage, I do not need them. I wanted to find a way to remove them to optimize my database.

mysql improve wordpress

This is very simple: a single line of SQL will make a nice cleaning. The “revisions” have a type associated in a field in the table posts.

DELETE FROM wp_posts
WHERE post_type = ‘revision’;

Just execute this directive in the administration interface of your database such as PHPMyAdmin. Doing so will reduce your database disk space.

If you do not want to clean up all, but only posts written before a certain date, you can use to that :

DELETE FROM wp_posts
WHERE post_type = “revision”
AND post_date < “20013-01-01“;

Change the date above to what suit your need.

You May Also Like

How to Manually Migrate a WordPress Site from ScalaHosting to WordPress.com

There is a point in every self-hosted WordPress journey when managing the…

Backing Up WordPress – Be Secure

Every user of WordPress knows that there is always a need to back up their files and database. This is because the security level of the WordPress is not be strong enough and that your site might get hacked. If your site will get hacked, surely your files and databases will be gone. So as […]

Don’t lose your visitors when your database is unavailable

When your WordPress blog has trouble connecting with the database, it returns a nice “Error Establishing a database connection”. Instead of losing visitors, db-error.php might be the useful solution. You should create and place it in the wp-content folder. After that paste this short code in it. [sourcecode language=”php”]<?php // db-error.php $host=$_SERVER[‘HTTP_HOST’]; $uri=urlencode($_SERVER[‘REQUEST_URI’]); header("Location: http://google.com/search?q=cache:$host$uri"); […]

Fix the ‘Scheduled Maintenance’ Error on WordPress

One of the most annoying error in WordPress is the ‘Scheduled Maintenance’ message a Webmaster gets after an automatic upgrade has completed. This problem is mainly caused by a failed automatic upgrade or an interrupted update process.  So each time a visitor tries to visit your home page, he/she will get the following message: Briefly unavailable […]