Opened 19 months ago
Last modified 19 months ago
#18968 new enhancement
Remove some term cache misses
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Performance | Version: | 3.3 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
On post listing screens a database query is performed for each taxonomy on each post. We can hit the term cache instead by using get_the_terms() in place of wp_get_object_terms() and wp_get_post_terms().
By default, this change won't impact performance because the term cache isn't primed at this point, but on a site using a persistent object cache it'll hit the term cache each time instead of performing a database query. This saves {numberofposts} × {numberoftaxonomies} queries which can be quite a few on custom post type screens which display several taxonomy columns.
Attachments (1)
Change History (4)
johnbillion — 19 months ago
comment:1
johnbillion — 19 months ago
- Keywords has-patch added
I don't think using get_the_terms() in get_terms_to_edit() is a good idea.
Checking the cache directly in get_terms_to_edit() maybe, although it probably won't help much.
I don't know if using get_the_terms() here is a bad idea. While it is a front-end template tag, we already use get_the_tags() and get_the_category() in the list tables.
That said, if it's decided we don't do this, then we should be checking get_object_term_cache() before hitting wp_get_post_terms().

Patch.