Home / Articles / WordPress / 7 Tips To Reduce WordPress Database Size

7 Tips To Reduce WordPress Database Size

Serious about speeding up your WordPress-hosted website?

Then you’ve likely shelled out money for a clutter-free design or codes that reduce the loading time of your site.

And if you’re anything like the typical webmaster, you eagerly devour the worksheets, ebooks and webinars that teach you to increase site speed.

But it turns out, you may not need to pony up some dough.

Why, you ask?

Because reducing the size of your WordPress database can significantly reduce your site’s loading time and improve its speed.

It’s no secret that search engines give a lot of importance to site speed, and that your website loading time can affect your search rankings in a small percentage. This does not specifically mean a faster website will boost your ranking, but it assists crawlers to access your web pages easily and provide a better user experience to visitors.

And the larger your WordPress database is, the more time it could take to render pages for those visiting your website. So it’s essential for you to cleanup your WordPress database and reduce its size. Over time, your database may have unused records, redundant entries and tables which you can safely remove without affecting other elements of your site. This will assist in removing the load time on your server and improve the performance of your site.

Curious about how to reduce the size of your WordPress database? What follows are seven steps to reduce WordPress database size that can be put into practice instantly:

1. Delete unwanted plugins

1

Did you know there are over 20,000 WordPress plugins? The ease with which you can install a plugin is a blessing and a curse at the same time. Your database will always suffer from plugin bloat, as each plugin, even when deactivated, adds more code for WordPress to load.

So do your database, and your site, a favor, and delete all those plugins you haven’t used in a while. This can be done easily through the plugin section in your WordPress dashboard.

2. Delete spam comments and unwanted codes

2

There should be comments and posts in your spam and trash folder: this is the unnecessary clutter you need to remove. You should also delete any post revisions that were left as drafts and new posts were published instead.

You can use the WP-optimize plugin to get the job done with a single click. At the same time, you can use Clean Options for WordPress plugin to find unused tables in your database and clean them as well.

3. Use MySQL queries

Akismet plugin increases the database size in many instances due to the table called wp_commentmeta. Install the WP db manager plugin > run the following two query options – they can be executed from the WordPress dashboard (but run each of them separately):

DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
DELETE FROM wp_commentmeta WHERE meta_key LIKE ‘%akismet%';

Your WordPress installation might be a bit different, so don’t forget to check your table name before applying the queries above. The following SQL queries are also helpful in reducing database size:

DELETE FROM wp_postmeta WHERE meta_key = "_edit_lock";
DELETE FROM wp_postmeta WHERE meta_key = "_edit_last";

4. Compress images

4

Compressing your images can greatly reduce the amount of data residing in your database. You can use gzip compression to reduce the size of text based resources such as CSS, JavaScript and HTML.

You can also use the WP Smush.it plugin that will compress images when you upload new ones to the media library by stripping meta data from JPEGs, converting GIFs to indexed PNGs, stripping the unused colors from indexed images, and optimizing JPEG compression. WP Smush.it will run quietly behind the scenes.

5. Turn off Autosave

WordPress saves the changes you make to posts every 2 minutes and stores them as revision. All the revisions of a single post are saved as separate entries in the database, which makes the database drastically large.

If you’re writing long posts, turning off the autosave feature is viable solution. Add the following code to your functions.php file between the closing and opening php tags:

function disableAutoSaveCompletely() {
 wp_deregister_script('autosave');
 }
 add_action( 'wp_print_scripts', 'disableAutoSaveCompletely' );

6. Optimize WordPress database

The database is the place where everything is stored: comments, settings, pages, posts, plugins and codes. A bloated database means every time a page is reloaded, it can take longer for the information to be found and displayed.

This is why you need to optimize your database. Using WP-DB manager or WP optimize plugin is a great way to restore, repair, optimize and backup your database.

7. Use cache plugins

Caching plugins such as W3 Total Cache create a static version of your pages for first time visitors. So the database is accessed to generate your page when someone visits it for the first time.

With a cache plugin, the generated page is stored on the server, so when a user visits a page for the next time, the same page is pre-generated and the database isn’t called in.

Take the following measures to optimize your WordPress database. You’ll notice instant results.

Photo of author

Article by Dan Virgillito

Keep Reading