[wp-hackers] WP_Query loop generates a lot of mySQL queries
Otto
otto at ottodestruct.com
Mon Oct 29 20:38:46 UTC 2012
Turn off the meta and term caching, since you're not using them in
that Loop. Set 'update_post_meta_cache' and 'update_post_term_cache'
to false in your WP_Query's.
-Otto
On Mon, Oct 29, 2012 at 2:17 PM, Dusan Dzurdzic
<dusan.dzurdzic at gmail.com> wrote:
> Hello friends,
>
> I would like to start a discussion regarding wp_query() loops, both for
> single loop on a page, or for multiples wp_query() loops on the same page.
>
> I'm creating a template with a few pages. On index page I'm retrieving posts
> from a few different custom post types, with a few wp_query() loops. On the
> other page, eg domain.com/somepage I'm using one loop to retrieve certain
> posts. On that page, I'm producing around 5 mySQL queries per returned post
> (posts_per_page=1), for 5 posts (posts_per_page=5) I'm getting around 30
> mySQL queries.
> On the index page, domain.com, for 4 columns multiple with 5 posts_per_page,
> I got around 130 mySQL queries. Obviously I'm not getting an array with
> posts information.
>
> Is there any way to merge them, or something similar. Maybe another
> approach.. I have pasted my code on pastie, for easy lookup:
> http://pastie.org/5130894 .
>
> I saw few more peoples on wordpress.org/support and
> wordpress.stackexchange.com troubling exact problem, but there were no any
> answer, so I'm writing to You (wp-hackers lists on automattic).
>
> Thanks
>
> Dusan Dzurdzic
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list