WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 9 months ago

Last modified 8 months ago

#16621 closed enhancement (maybelater)

Check term cache in _transform_terms()

Reported by: misterbisson Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Taxonomy Keywords:
Focuses: Cc:

Description

WP3.1's awesome new taxonomy query stuff rocks, but WP_Tax_Query->_transform_terms() seems to be executing multiple identical queries on each page load. The front page of one of my sites gives me five of the following query:

SELECT wp_1_term_taxonomy.term_taxonomy_id
FROM wp_1_term_taxonomy
INNER JOIN wp_1_terms USING (term_id)
WHERE taxonomy = 'channel'
AND wp_1_terms.slug IN ('tech')

I understand the function can do a lot more than map a single term+taxonomy to a term_taxonomy_id, but it also looks like there'd be some performance benefit from checking the term cache rather than the DB in those situations.

Or, perhaps it'd be enough to simply cache the result for the duration of the page load.

Or, maybe I'm focusing on the wrong problem, as the query takes just 1-2ms to execute.

Change History (5)

comment:1 scribu3 years ago

The trouble is that we can't retrieve cached terms by slug, only by term id.

I guess we could still check the cache when transforming from a term id.

comment:2 misterbisson3 years ago

@Scribu: sorry, you're right. I had been certain that WP maintained a cache addressable by term slug. I was wrong and probably guilty of wishful thinking.

Are there strong arguments against maintaining such a cache?

comment:3 scribu3 years ago

  • Type changed from defect (bug) to enhancement

See #14983

Last edited 3 years ago by scribu (previous) (diff)

comment:4 ericmann9 months ago

  • Resolution set to maybelater
  • Status changed from new to closed

Closing for now until we have some more progress on #14983.

comment:5 dd328 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.