How to Optimize a WordPress Database to Run Faster

Remove unnecessary data, improve tables that are used on a regular basis and speed up your site manually or via a free plugin

“If your business isn’t online, it doesn’t exist” was a common saying in the middle of the last decade. It was, is, and will be true, but it’s no longer enough. Nowadays, your business not only needs a website but it should load quickly on any mobile device. People aren’t patient enough to wait for your site to load. Improving loading speed is a WordPress user’s nightmare because it depends on many factors. Plus, improving speed often means reducing the complexity of the site. You need to find the sweet spot of functionality vs. loading-speed limitations. Keeping your website fresh and well organized is your starting point in excelling to greatness, and with the presence of tools like Plutio it’s a much easier task to achieve. Ranging from organizing your tasks, describing different file formats, customizing workflows, custom fields and various other features, optimizing your business environment has never been an easier task to complete.

In this context, no method of improving the loading speed can be neglected. You will find a plethora of guides in this respect, and many of them contain useful tricks. However, a vast majority of them miss an excellent method of reducing the loading time: optimizing the WordPress database correctly. Optimizing a database may sound daunting to less-experienced WordPress users. Stick with us, and let’s get our hands dirty with it.

WordPress Database

WordPress database
During a standard WordPress installation, 12 tables are created to store necessary information about your website. Check out “Database Description” from WordPress Support to get an idea about each table. These tables store, amongst other things, blog posts, pages, comments, pingbacks, post revisions, and drafts.
Certainly, you will install plugins that will create other tables (e.g., one of my blogs has 46 tables). They store helpful and unhelpful information so you will need to get rid of useless data. Once you delete that bloating data, your WordPress databases will run faster, and as a result, your website will also load faster.

How to Optimize WordPress Databases

Prior heading to your databases, make a complete backup of your website. Don’t skip this part because any error could crash your entire site!

You have to access WordPress databases through PhpMyAdmin or a similar tool if your host doesn’t use cPanel. Select your database, and it will display all of your website’s tables. You can perform different actions for each table separately or collectively.

phpMyAdmin
In our case, I suggest checking all your tables (PhpMyAdmin has a built-in option to check all tables) and select them to optimize. It may take a few seconds depending on your database size, and voila! You have optimized your website!

Optimize WordPress tables

Tricks to Remove Worthless Data

Even though you have optimized the database, the game isn’t over. It will refill with garbage or useless data. Here are a few tricks that will help you reduce the bloat.

1. Revisions

Revisions are genuine gold for bloggers because it’s so easy to ruin a post. In case of a disaster, you can load a revision and start working on that. WordPress doesn’t have a limitation regarding the number of revisions. It could have 30 revisions for a single post. Of course, these revisions aren’t all necessary, and they bloat the database.
Limit the number of revisions stored in your database. Head to your file manager, open up the wp-config.php file, and insert this line of code:

define( 'WP_POST_REVISIONS', 3 );

Now WordPress will save only the latest three revisions. Feel free to change the number of revisions to suit your needs.

2. Autosaves

WordPress autosaves your articles every 60 seconds. To avoid bloating the database, you can change this interval. Just go to the wp-config.php file and add the following line of code:

define( 'AUTOSAVE_INTERVAL', 240 );

Feel free to change the interval of time to suit your needs; the time is measured in seconds.

3. Trash

Your database bulks with trash because, by default, WordPress stores deleted items for 30 days. You can reduce this period to make your website run faster. As you have probably deduced, go to the wp-config.php file and add the following line of code:

define( 'EMPTY_TRASH_DAYS', 3 );

Feel free to change the trash-emptying interval to suit your needs.

Plugins to Optimize WordPress Database

You can optimize your WordPress database manually, but it’s inconvenient, and you have to remember to do it regularly. Instead, a plugin can do it regularly and even better than you can. Before we show you the three top-notch suggestions, you should also know that there are some even more convenient options.

If you’re not that technical to optimize a database by yourself or even with the help of a plugin, you could try the web hosting company Templ. They offer free speed optimization, including database optimization. In order to prove this, guys at Templ allow you quickly start with a free account so you can test a new site on their servers.

1. WP Optimize

WP Optimize plugin
This plugin is the most frequently used for database optimization, and users rate it excellently. WP Optimize is user-friendly and can be utilized even by newbies. Once you install and activate it, you can perform table optimization and enable periodic cleanups.
This plugin does many other useful things such as removing unnecessary post revisions, deleting pingbacks and trackbacks, showing database stats, and it retains a set number of weeks the cleaned data.

2. WP-DBManager

WP DBManager
This plugin is an alternative to WP Optimize. It performs any type of action on your database. WP-DBManager repairs, optimizes, and restores a database and drops or empties tables. It also lets you set up a periodic cleanup.

3. Plugins Garbage Collector

Plugins Garbage Collector
It’s almost impossible not to use a plugin for your WordPress site. The chances are that you have installed and deleted plugins, but you didn’t pay attention to the tables left in your database. Manually cleaning these tables is time-consuming, and you might delete useful data.
Plugins Garbage Collector plugin has an inspired name. It removes the tables created by deleted plugins so that the database will run faster.

4. DevKinsta

DevKinsta is yet another exceptional tool for every website owner, as it enables you to build and test code locally, which means that internet connectivity is obsolete, and everything is oversimplified to speed up the entire process. Furthermore, it has a built-in Database Manager which provides additional ease for its maintenance and expansion, and when everything is set up and ready to roll, you can push your site directly to Kinsta.

Final Words

What do you think – is that hard to optimize a WordPress database? Doing it manually is a little bit riskier than using a plugin because you could delete useful data. Using a plugin is safer, but installing a plugin slows down the loading speed of your site. Please let us know what you think about database optimization and which method is better for you. We are waiting for your input.

Have a Look at These Articles Too

Published on October 17, 2017 by Daniel; modified on November 23, 2021. Filed under: , , , .

Daniel is a writer on WP Newsify, a blogger & Internet marketer ready to create valuable, actionable and interesting content for your website. He is in love with WordPress and Internet Marketing. Follow WP Newsify on Facebook and Twitter.

2 Replies to “How to Optimize a WordPress Database to Run Faster”

Leave a Reply