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:
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!
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