[wp-trac] [WordPress Trac] #62123: Improve performance of get_ancestors() with recursive common table expression.

WordPress Trac noreply at wordpress.org
Wed Oct 1 18:54:09 UTC 2025


#62123: Improve performance of get_ancestors() with recursive common table
expression.
-------------------------+------------------------------
 Reporter:  Chouby       |       Owner:  (none)
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Taxonomy     |     Version:  3.1
 Severity:  normal       |  Resolution:  wontfix
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------
Changes (by Chouby):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 After doing some tests, the proposal proves to be counterproductive in
 practical use cases.

 For example, in the terms list table, terms are added to the cache prior
 to the call to `get_ancestors`. So in this use case, probbaly the most
 frequent, the calls to `get_term()` in the function don't query the DB.

 On the opposite, with this proposal, each call to `get_ancestors()` would
 result in one extra DB query.

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


More information about the wp-trac mailing list