The current site I'm building has a homepage that is going to have around 10 instances of WP_Query(). Some of them are going to pull a series of posts, while others are targeted at one single post based on ID number.

How should I optimize page load speeds when dealing with this many instances of WP_Query()? Is using a caching plugin enough? Is there something else I should be doing in addition? Or should I not even worry about it because 10 database queries will not result in a significant performance decrease?


There's never one magic answer to broad performance questions. It's like choosing a vehicle -- the best choice for one person or situation may be a lousy choice for another. Here specifically, it's even more granular: the best answer for one query maybe not even be the best answer for another! There isn't enough information here to even provide good advice, for lots of reasons. Among them:

  • Query specifics; two queries may be radically different in performance, so one perhaps could be left alone while another should use a transient.
  • How often the data will change; one query perhaps should be cached indefinitely with a refresh on post update, while another not cached at all.
  • Whether or not full-page caching will be present
  • Whether or not you're using Memcached (or similar)
  • The size of the post and taxonomy tables

The best thing you can do is implement it and see how your SQL performance fares using the Debug Bar Plugin or similar, then make decisions or ask more pointed questions based on that data. It would also be a good idea to take a step back and ask yourself if any of the queries could be combined, and then separate the posts using PHP.

At the very least, I can offer this: there's rarely a reason to not use some form of full-page caching, which may make what you do here a little less significant depending on how long you can cache the page. My go-to solutions for this are Varnish, WP Super Cache, or Batcache, depending on the server architecture.

I hope this can at least point you in the right direction, and help you get your feet off the ground!

  • Thanks that's all very helpful information! I realize that my question does not have a specific "right" answer, and you have touched on several different paths that I can explore. I come from more of a front-end background, so I still have a lot to learn in this area. – Evster Oct 7 '13 at 22:19

What kind of traffic is the client pulling in? If you're talking about 10k visits per hour, then it matters. If you're talking about fewer than that a day, then you're probably optimizing something that doesn't matter.

You should find this previous topic enlightening.

Can I use WP_Query one time and then filter the results multiple times

  • I'm guessing at very best the site would be getting several thousand unique hits per day. Definitely not more than a couple hundred per hour. Thanks! – Evster Oct 7 '13 at 22:20
  • Good grief. You asked how to limit WP Query calls so I answered the question. You filter one query. For that I get a -1 while someone to talks about a caching plugin gets the answer. Best of luck dude. – Imperative Ideas Oct 9 '13 at 19:55

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.