[wp-trac] [WordPress Trac] #5377: Defer term counts during multiple
inserts
WordPress Trac
wp-trac at lists.automattic.com
Wed Nov 21 11:23:05 GMT 2007
#5377: Defer term counts during multiple inserts
------------------------+---------------------------------------------------
Reporter: tellyworth | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.5
Component: General | Version:
Severity: normal | Keywords:
------------------------+---------------------------------------------------
wp_update_term_count() gets called any time a post is inserted with tags
or categories. It can cause several queries and cache invalidations per
post insert, which adds up quickly during an import.
The enclosed patch provides a wp_defer_term_counting() function that can
be used to temporarily disable term counts when inserting multiple posts:
{{{
wp_defer_term_counting(true);
do_many_inserts();
wp_defer_term_counting(false);
}}}
Any deferred counts will be automatically updated when
wp_defer_term_counting(false) is called. My testing shows this saves
about 6500 queries on a 500 post import.
The patch doesn't touch the import code yet, I wanted to post it for
separate review first because it's probably useful elsewhere.
--
Ticket URL: <http://trac.wordpress.org/ticket/5377>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list