My website's been incredibly slow and I installed the query monitor plugin to learn more about the issues that caused this.

When loading my index page, the following query takes 0,2412 (seconds?!) to load, and it's coloured in red in the plugin so I guess this has something to do with the slow loading process.


SELECT * FROM wp_posts WHERE ID = 684 LIMIT 1

What exactly does this query execute and what can I do to make it less impactful on the site? There is also a caller, which is:


Although a quarter of second is quite slow to query a single post from db, I'm convinced that this is not your only issue. I also use the Query Monitor plugin, but I have never really taken note when does the plugin redline a query as being slow. But that is not the point here.

Because one tend to focus on something as explicit as a red line, one redline query can mask 100 queries that are just below radar which combined can add up to a couple of seconds loading time. You need to take all of this into consideration. On average, a page should not be doing more than 30 queries, anything more than this should be investigated. Make sure that you look at the big picture and check how many queries is actually performed on a page load and the time that is spend to run all of these queries.

It should be noted, apart from just looking at queries, there are many other parts of the puzzle that adds up to how fast or how slow a page load. Loading scripts, styles, images, elaborate background and header images, fonts, the size of the db, type of date, etc etc, this is all factors that can slow pages down. Then there is the server you are on as well. Crappy low cost hosts uses low budget servers that are slow, specially when loaded.

Optimizing a site to load faster is an intensive process that cannot be discussed here. IMHO, it is better to hire a professional to examine your entire site (db, theme, plugins, server, data, etc etc) and how it is setup and how everything integrates into one another, and then based on that give specific solutions to your issues.

Just a quick note, optimization usually involves like minifying scripts, caching styles, query results, page content, adding heavy queries into transients, that kind of stuff. As for your exact question, what the query in OP does is a mystery to me as I do not know the setup of your site and page. If this query is performed by the theme itself, you should call the author. As for optimization, you can always add the query in a transient or cache the result from the query, but as I said, a specific solution would require knowledge of the theme and what the query exactly does in the context of the theme or page

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.