Slow WordPress Queries

I love working with WordPress, it makes so many things easier for clients and it gives me as a web developer a great deal of flexibility to extend and offer to clients what they need for their websites. Unfortunately there are also times working with WordPress makes me scratch my head, this was one of those times.

One of my clients WordPress websites seemed to be crawling, it was just not loading quickly at all yet nothing seemed to have changed on the site. There had been a slight change with the main menu on the site so I thought perhaps there was a problem with the new menu options and I decided to log the slow MySQL queries to see I could find out.

After awhile I came back to look at the the MySQL slow queries log and to my surprise I found the following slow query over and over again:
SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';

I was shocked by the fact that the main problem with the site seemed to be the main options table. After doing a little Googling on the query I came across this excellent post “WordPress wp_options table autoload micro-optimization” and decided to try adding an index to the wp_options table and see if it helped speed up the clients WordPress website.

While the post I linked to used the command line, I actually used PHPMyAdmin to add the index to the autoload column. I am always cautious when working with the WordPress database, so I made sure I had a backup copy of the database before messing with it, and added the index. I then cleared the MySQL slow queries log and waited. Of course I checked the clients website to make sure everything looked ok and I was optimistic this had fixed the problem. The site was already responding much faster than it was earlier.

After a few hours I went and checked the slow queries log again and the slow queries on the wp_options table had disappeared. There are still some slow queries to deal with including one with WordPress SEO from Yoast and transients but the wp_options autoload query seems to be fixed for now.

What I am not sure of, is why does the WordPress team not have an index on the autoload column? Considering how much the options table is used to store plugin and theme data (with right or wrong I will not comment) but the fact that the options table is used for saving WordPress transients would suggest to me that perhaps that column should be set with an index by default.

If your WordPress website is starting to seem a little sluggish this is something else you might want to look into doing to speed your website up. If you are not comfortable with working with your WordPress database feel free to contact me I will be glad to help.

Service Disruption – iWeb Montreal Data Center

If there is one thing I hate it is when my clients websites go down. I work hard to keep the server software and client websites software up to date to keep the sites up and the servers running as best as they can. There are things outside of my control that can make all…Continue Reading

WordPress Rel Nofollow Checkbox Plugin

WordPress Rel Nofollow Checkbox Plugin

Adding the rel=”nofollow” on links in WordPress can be a pain especially if you want some links to be nofollow and some to be followed. Thankfully with the WordPress Rel Nofollow Checkbox plugin you can simply create your links how you normally would and just select the checkbox if you would like it to be…Continue Reading

Website Backup

I published a post yesterday over on Cloud Storage Buzz listing 10 ways to backup your website to the cloud. There are a lot of services out there that can help you protect your website and while many of the services I mentioned at Cloud Storage Buzz will help you keep a regular backup of…Continue Reading

Unsplash WP Plugin

I am always on the lookout for new and interesting photos for use in websites, blog posts and to pass on to clients. There are several places you can get free photos to use, in fact here is a list of 30 of them, but finding the perfect photo, downloading and uploading it again in…Continue Reading

World Backup Day 2014

I don’t usually cross post stuff from Cloud Storage Buzz here on LGR Internet Solutions but this is important and needs to be talked about everywhere. Today, March 31st, is World Backup Day and I want to remind you to make sure you have a backup of your data. If you do already have a…Continue Reading

Use CloudFlare Page Rules to Protect WordPress from Brute Force Attacks

I have talked about CloudFlare before and there are many reasons why you should use them, from helping to speed up your website to making it easy to monetize your website using Viglink. If none of those reasons convinced you why you should use CloudFlare perhaps this one reason alone will help convince you. You…Continue Reading

TinyPNG Plugins

TinyPNG Plugins

Optimizing your WordPress site to be faster is good for your users, but it is also good for your search engine results. It is one of the things that is in your control. One of the best ways to optimize your PNG images is to use TinyPNG. Previously you had to manually use the site…Continue Reading

Web Hosting Recommendations

It has been awhile since I talked about web hosting so I thought I would update everyone on what I am using and what web hosting I have been impressed with over the last year. As many of you know I have and host many of my clients websites on my dedicated server through iWeb.…Continue Reading

3 Easy Tools to Name the Theme

3 Easy Tools to Name the Theme

A common question from people as they are searching for a theme for their WordPress website is what theme is ____ website using? If you know HTML/CSS it is pretty easy to look at the code and determine what the theme is and where that website got it from. If you don’t know HTML/CSS here…Continue Reading