Optimizing WordPress Database Servers

It’s common, and frustrating, for WordPress sites to be slow. When a site is slow for visitors, they give up and go elsewhere. When the dashboard is slow for site owners and content editors, it makes it harder to maintain the site, post new stuff, and handle orders (if it’s a store).

Database Optimization Plugins

I have several free open-source WordPress plugins that help optimize your WordPress’s database server operations. Almost all WordPress sites use either a MySQL or MariaDB database server, and these plugins help optimize those operations.

Index WP MySQL For Speed adds high-performance database keys. It resolves many performance issues on sites with many posts, pages, or products. Many sites can benefit from this plugin.

Index WP Users For Speed resolves some performance problems on sites with many thousands of registered users.

SQLite Object Cache provides a persistent object cache that works on many hosting providers. The point of a persistent object cache is to reduce the load on your MySQL or MariaDB database server. It can help busy sites, or sites on overloaded shared hosting services. There are other plugins providing persistent object caches. You can read about them here. Many sites can benefit from an object cache.

Fast Woo Order Lookup is for WooCommerce stores that have many orders. It resolves performance problems that store managers have when searching for orders from customers. If you have fulfilled thousands of orders through your store, this plugin helps you find them.

What is this about?

This article is about site slowdowns caused by database servers. There are many reasons a site can be slow. Some of them have to do with slow overloaded shared hosting. Others have to do with images that can be compressed more efficiently. Still others have to do with “heavy” page designs–pages that take too many kilobytes of data. Many authors have written good material about those problems, and this article isn’t going to discuss those problems in much detail. The focus here is on database servers.

Is my database server too slow?

All WordPress sites have a database server, and almost all use either MariaDB or MySQL software for those servers. First of all, unless you have hundreds of posts, pages, products, or other kinds of content on your site your database is almost certainly not the cause of your slowness.

What is slow about my site?

How can you measure the performance of your site? An easy way is to use the Lighthouse feature in your Chrome browser’s devtools. To measure accurately do these things.

  1. Open an incognito or private browser window. This makes sure you measure the same sort of things your web site visitors experience.
  2. Visit your site’s front door page. That is, if your site is https://www.example.com/ , visit that page.
  3. Open devtools and find the Lighthouse tab. Push the Analyze page load button. When the report comes up examine it. It will suggest improvements. It is wise to examine those suggestions and take action on them if you can.
  4. Look for the initial server response time — the Time To First Byte or TTFB — in the Lighthouse report on your front door page, and make a note of it. This is the time it took for your WordPress site to begin responding to your browser’s request for its page. A slow TTFB here means your database server might be slow.
  5. In an ordinary browser window open your site’s dashboard (https://www.example.com/wp-admin/) and run Lighthouse on it. Note the TTFB from that report as well. A slow TTFB here also means your database server might be slow.
  6. Many WordPress installations have a simple HTML file in them, at https://www.example.com/readme.html. Open that page in your incognito or private window, and run Lighthouse on it. Note that TTFB as well. If the TTFB from your readme.html file is slow, that is a good sign that your hosting service is overloaded and slow. Delivering the readme.html file to your browser is the simplest operation a web server can do.

Look for the TTFB on your site’s front door page. If it is long, it is possible you have slowness caused by your site’s database server. In the same way, look at the TTFB on your dashboard page. If it is long, you may have database server slowness too.

Again, there are many reasons a web site can be slow. This post only considers database slowness.

How can I find out more about my site’s slowness?

Query Monitor, by John Blackbourn, is a plugin that shows the database queries (database operations) that WordPress uses to deliver each page to you or to your viewers. It highlights slow queries and other inefficiencies in the operation of WordPress. Interpreting the detailed output of that plugin takes a bit of knowledge, but if you consistently slow queries it will make that situation clear. Caution: if you use Query Monitor on a production site, be sure to deactivate it when not using it. It has significant overhead.

You can try using my Index WP MySQL For Speed plugin. Install it, activate it, and then use it to add high-performance keys to your database tables. If it helps your performance, that means it mitigated your database server inefficiencies.

You can try using a persistent object cache, either my SQLite Object Cache or another one.

Of course, if you decide to use a plugin, please read its instructions carefully.

Leave a Comment