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

The Real Cost of “Just One More Plugin”: A WordPress Bloat Audit

Plugin count is a bad proxy for plugin cost. Here’s a category-based audit that finds real performance savings a “delete unused plugins” tip misses entirely.

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…

WordPress Hack: remove “WordPress Generator”

The publishing platform WordPress adds a small line for itself to advertise and clarify that the site that you find is a site using WordPress. Except that in addition to reporting that it’s WordPress, it goes to show the current version.It is not embarrassing, except that each version has its security problems… Past one of […]