[wp-trac] [WordPress Trac] #56598: Performance optimization in _update_post_term_count()

WordPress Trac noreply at wordpress.org
Fri Sep 1 04:27:58 UTC 2023


#56598: Performance optimization in _update_post_term_count()
-------------------------------------------+--------------------------
 Reporter:  dimitrisv                      |       Owner:  (none)
     Type:  enhancement                    |      Status:  new
 Priority:  normal                         |   Milestone:  6.4
Component:  Taxonomy                       |     Version:  6.0.2
 Severity:  normal                         |  Resolution:
 Keywords:  needs-patch reporter-feedback  |     Focuses:  performance
-------------------------------------------+--------------------------

Comment (by peterwilsoncc):

 Replying to [comment:9 joemcgill]:
 > This seems like a useful optimization, but we'll need a PR (or patch)
 for it to make this release. @peterwilsoncc are you interested in owning
 this one?

 I'll need to see some EXPALINs showing the cost goes down. `count(*)` is
 DB speak for "count the number of rows the WHERE clause returns",
 `count(field)` is DB speak for "count the number of rows the WHERE clause
 returns in which `field` is a non-null value" -- so it's possible there
 will be a performance hit.

 While it might be possible to improve the existing queries, I think it's
 papering over the cracks rather than fixing the underlying issue that term
 counting queries the entire table rather than incrementing or decrementing
 the count as posts are published or unpublished or terms are added or
 removed.

 The reverted patch on #40351 got very close to implementing partial
 counts, it just needs some improvement to account for a few edge cases.
 WPVIP use partial counts with some success.

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


More information about the wp-trac mailing list