Opened 14 years ago
Closed 11 years ago
#18968 closed enhancement (fixed)
Remove some term cache misses
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 3.3 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | performance | 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 (3)
Change History (12)
#2
@
14 years ago
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.
#3
@
14 years ago
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().
#5
@
12 years ago
- Cc jeff@… added
- Keywords needs-refresh removed
Updated the patch against r25222 so it can be tested again.
#7
@
11 years ago
- Milestone changed from Awaiting Review to 4.0
This is patched and can be investigated for inclusion in our 4.0 Taxonomy work
#8
@
11 years ago
*Testing of Posts list table:*
Without patch, non-persistent:
DB: 61
CACHE: 1621
Without patch, with Memcached:
DB: 49
CACHE: 1602
With patch, non-persistent:
DB: 21
CACHE: 1701
With patch, with Memcached:
DB: 9
CACHE: 1682
*With the check for cache in get_terms_to_edit()
:*
non-persistent:
DB: 41
CACHE: 1641
with Memcached:
DB: 29
CACHE: 1622
*An alternate approach in get_terms_to_edit() - basically the
get_the_terms()
cache logic that doesn't hit a filter:*
non-persistent:
DB: 21
CACHE: 1681
with Memcached:
DB: 9
CACHE: 1662
Ding ding ding!
*Without the call to get_the_terms()
for hierarchical*
Non-persistent:
DB: 41
CACHE: 1641
Memcached:
DB: 29
CACHE: 1622
Patch.