[wp-trac] [WordPress Trac] #21760: get_term_by() calls are not cached

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 4 17:40:13 UTC 2012


#21760: get_term_by() calls are not cached
----------------------------------------+------------------------------
 Reporter:  wonderboymusic              |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Taxonomy                    |     Version:  2.3
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |
----------------------------------------+------------------------------

Comment (by wonderboymusic):

 Another piece of this - get_terms calls update_term_cache if you got all
 the fields, regardless of checking the hide_empty arg.

 {{{
 $terms = $wpdb->get_results( $query );
 if ( 'all' == $fields ) {
         update_term_cache( $terms );
 }
 }}}

 I did a performance test where I created 20,000 tags and called get_terms(
 'post_tag', array( 'hide_empty' => false  ). This will create 60,000 cache
 entries which exhausted memory until I bumped up to 256M. I tested posts
 with 1000 tags and they seemed fine, but this one may need to exclude
 terms with count of 0 before calling update_term_cache with every returned
 term

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21760#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list