[wp-trac] [WordPress Trac] #23061: get_post_meta() on post with large amount of meta keys uses too much memory

WordPress Trac noreply at wordpress.org
Wed Nov 29 15:48:31 UTC 2017


#23061: get_post_meta() on post with large amount of meta keys uses too much memory
-------------------------+--------------------------
 Reporter:  joehoyle     |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:
Component:  Database     |     Version:
 Severity:  normal       |  Resolution:  wontfix
 Keywords:               |     Focuses:  performance
-------------------------+--------------------------

Comment (by xParham):

 I am running into a similar issue with only 10 meta entries per post where
 one of the entries is ~2-3MB large. Requesting any single one of the meta
 entries results in pulling in all meta entries which is not desired for
 example on a post listing page.

 In my case, using memcached with the default max object size of 1MB,
 `update_meta_cache()` failed to cache the meta entries and then accessing
 individual meta entries using the magic method of the post object was
 making a new DB query for every single meta access, 300 queries for
 accessing 10 meta entries for 30 posts.

 I think it would be great if we can implement a mechanism to exclude some
 meta keys from the query in `update_meta_cache()`.

 Maybe the `update_post_meta_cache` parameter of `WP_Query` can accept
 arrays of meta keys to include or exclude, which will then passed to
 `update_meta_cache()`? Or maybe as @joehoyle originally suggested, a
 filter in `update_meta_cache()` so one can adjust the query?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23061#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list