[wp-hackers] multiple calls to get_post_meta back to back as opposed to one call
halukkaramete at gmail.com
Thu Feb 7 22:05:19 UTC 2013
I assume that this caching is handled regardless of the
What I'm curious though is how the caching is handled in this particular case?
Where does WP store the cached results for a get_post_meta?
In memory? As a file? in /cache folder as in define('ENABLE_CACHE',true);?
What's a good URL for learning more about this internal caching?
On Thu, Feb 7, 2013 at 1:55 PM, Haluk Karamete <halukkaramete at gmail.com> wrote:
> Very interesting. I would have never guessed that that would be the
> case. Smart!
> On Thu, Feb 7, 2013 at 1:43 PM, Andrew Nacin <wp at andrewnacin.com> wrote:
>> On Thu, Feb 7, 2013 at 4:30 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:
>>> This question can be formulated as
>>> Would it make sense ( from the mysql quiery point of view ) to build a
>>> functionality so that the following 2 liner code
>>> $fields = array('field_1','field_2',....'field_10');
>>> will practically be speaking equal to something like
>>> $field_1 = get_post_meta($post->ID,'field_1',true);
>>> $field_2 = get_post_meta($post->ID,'field_2',true);
>>> $field_10 = get_post_meta($post->ID,'field_10',true);
>>> First approach will be done with a single but slightly more
>>> complicated query whereas the latter will force 10 sql queries they
>>> tend to be simpler.
>> Test this and you will find that the latter is just one query, total. When
>> you call get_post_meta(), all meta for that post is queried and cached.
>> Additionally, only the first argument to get_post_meta() is required. Call
>> it with just a post ID and you'll get back all metadata.
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
More information about the wp-hackers