[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
Thu Dec 27 13:40:18 UTC 2012


#23061: get_post_meta() on post with large amount of meta keys uses too much memory
-----------------------------+-------------------------
 Reporter:  joehoyle         |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Database
  Version:                   |   Severity:  normal
 Keywords:                   |
-----------------------------+-------------------------
 I think it's likely there has been a ticket on this in the past, but I
 couldn't find one so here goes!

 If I have a post that have say 25k post meta entries, and I call
 `get_post_meta( $id, 'foo', true )` then `update_meta_cache` is going to
 cause all post metas to be loaded into memory.

 In most cases I can see this makes sense, however I recently had an issue
 where I was storing contest votes as meta keys, a post had 30k votes, and
 would take about 70MB of memory to get any meta key of that post (even if
 I didn't want votes). This is fairly edgecase, but the idea that all meta
 for a post is always loaded even if you don't want it is perhaps over
 presumptuous as a dev may be storing a large amount of data in meta.

 With persistant object caching this is somewhat worse, as the object cache
 store gets very large.

 I am not proposing this functionality is removed, maybe just a filter or
 something in http://core.trac.wordpress.org/browser/trunk/wp-
 includes/meta.php#L524 so one could either adjust the query or perhaps
 pass an array of meta keys to exclude from the sql query

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23061>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list