[wp-trac] [WordPress Trac] #36846: Allow get_terms() to return slug&name fields

WordPress Trac noreply at wordpress.org
Mon May 16 22:46:05 UTC 2016


#36846: Allow get_terms() to return slug&name fields
------------------------------------------------+--------------------------
 Reporter:  ramiy                               |       Owner:
     Type:  defect (bug)                        |      Status:  closed
 Priority:  normal                              |   Milestone:
Component:  Taxonomy                            |     Version:
 Severity:  normal                              |  Resolution:  wontfix
 Keywords:  has-patch dev-feedback 2nd-opinion  |     Focuses:  performance
------------------------------------------------+--------------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 Hi @ramiy - Thanks for the patch.

 I'm against adding new values to `fields`. While there may be a narrow set
 of cases where selecting only `slug` and `name` will result in meaningful
 performance benefits, I think it's going to be exceedingly rare. In
 contrast, use of `fields` causes a lot of confusion with respect to
 caching: we currently keep separate copies of term queries in the cache
 for each potential value of `fields`. This pollutes the cache, by
 potentially multiplying the cache footprint of `get_terms()` by three or
 four times what it actually has to be.

 A better strategy is for the main terms query to be for IDs only, and the
 term objects fetched individually from the 'terms' cache. This work was
 begun in #34239 for `get_the_terms()`, and the patches on #35381 will
 extend the strategy to `get_terms()`.

 If you're able to demonstrate that `SELECT slug, name ...` is more than a
 microoptimization over `SELECT *` in a real-world situation, we can
 reconsider the proposal.

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


More information about the wp-trac mailing list