[wp-hackers] Putting meta and terms in post object
William P. Davis
will.davis at gmail.com
Tue Jul 19 20:06:37 UTC 2011
Thanks Otto. I'll do some investigation. We are using object caching via memcached, but it seems we're still not loading all this in advance and moreso that the same queries are being run multiple times. Any ideas what might be causing this?
Sent from my BlackBerry® wireless device
From: Otto <otto at ottodestruct.com>
Sender: wp-hackers-bounces at lists.automattic.com
Date: Tue, 19 Jul 2011 15:01:11
To: <wp-hackers at lists.automattic.com>
Reply-To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Putting meta and terms in post object
In normal WP_Query calls, meta and terms are both pre-loaded and
cached in memory by default *if* you're using an external memory based
object cache such as memcached or similar. By doing this, they can get
loaded into the object cache and thus these rather heavy queries don't
happen every single time.
However, if you're not using such a memory caching mechanism, then
yes, it doesn't load these on the query, since they're heavy. This
relies more on late-loading. They're loaded when you first need them,
then saved in the object cache in case you need them again. If you
know that you will need them in advance, you can just pass
'cache_results' => true to your WP_Query and the meta/term info will
be preloaded and object cached. Later hits for them will go straight
I highly recommend performance testing this heavily before deploying.
Loading these advance isn't necessarily the best way to go in all
cases, and in the case where it is (with persistent object caching),
it's the default.
On Tue, Jul 19, 2011 at 2:52 PM, William P. Davis <will.davis at gmail.com> wrote:
> We use a lot of post meta and taxonomies on our website, including in the formation of the permalink. We query them all over the place, which seems exceedingly inefficient. I'm wondering if there's any big drawback to getting all of a post's postmeta and terms right off the bat and putting them in the post object rather than querying the db every time.
> Sent from my BlackBerry® wireless device
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
wp-hackers mailing list
wp-hackers at lists.automattic.com
More information about the wp-hackers