[wp-trac] [WordPress Trac] #9007: Poor get_category_children()
performance; rewrite to use get_term_children()
WordPress Trac
wp-trac at lists.automattic.com
Sat Jan 31 09:26:55 GMT 2009
#9007: Poor get_category_children() performance; rewrite to use
get_term_children()
--------------------------+-------------------------------------------------
Reporter: _timk | Owner: anonymous
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.8
Component: General | Version: 2.7
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
I'm working on a WordPress site with a few thousand categories. The
categories are structured a bit, with one master category, a few
organizational subcategories, and then the bulk of the remaining
categories under those.
I'm looking to get a list of children for one of the middle-tier
categories. Running get_categories() with the 'child_of' parameter calls
get_category_children(). This call hits the 30-second server time limit.
Outside the web environment, get_category_children() takes around a minute
and 40 seconds to build a list of 589 categories on a relatively powerful
desktop PC.
I'll attach a revised, non-recursive implementation of
get_category_children() that uses get_term_children() and runs several
orders of magnitude faster than the original in my environment. It
returns almost instantly.
--
Ticket URL: <http://trac.wordpress.org/ticket/9007>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list