Make WordPress Core

Opened 13 years ago

Closed 9 years ago

#18778 closed enhancement (wontfix)

Add filters to transform_query() to allow caching of queries created by this function.

Reported by: tott's profile tott Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: 2nd-opinion reporter-feedback needs-patch needs-unit-tests
Focuses: Cc:

Description

transform_query() works great on regular datasets, but if you run this on a large set of data it can get very expensive. adding some filters in here that could allow these queries to be cached would be benefitial.

Attachments (1)

transform_query_filters.diff (1.3 KB) - added by tott 13 years ago.

Download all attachments as: .zip

Change History (13)

#1 @SergeyBiryukov
13 years ago

  • Keywords has-patch added

#2 @scribu
13 years ago

  • Keywords close added

transform_query() is a private, intermediary step. I don't think it should be made public through a filter.

Why not cache the final result?

#3 @tott
13 years ago

The problem is that even with something like advanced-caching enabled these queries are fired in order to built the final query. So even if you would add caching on the final query it would still execute these queries on the way to build the final one. At least as far as I experienced this. Where would you hook into to avoid this queries?

#4 @scribu
13 years ago

  • Keywords 2nd-opinion added; close removed

I was thinking of the case where you can prevent the whole call to WP_Query by caching the list of posts. Not sure how practical that would be for the main query.

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

#5 @scribu
13 years ago

PS: 'transform_query_' is too generic. Maybe 'transform_terms_query_'.

#6 follow-up: @westi
13 years ago

The filter names here don't make sense to me.

If the idea (as it seems it is) is to suppress the code from running the queries that I would expect "suppress" to be in the name of the filter.

However, I'm not sure yet this is even the right place to be doing the suppression - maybe we should be doing it where we call the function instead?

#7 in reply to: ↑ 6 @tott
13 years ago

It is not really about suppressing the call. It's more about simply filling $terms with the necessary values without a db query. This would be the place where plugins like advanced-caching could jump in to avoid the query.

#8 @tott
13 years ago

I will see if I can wrap up a standalone example to point out the issue.

#9 @chriscct7
10 years ago

  • Keywords reporter-feedback added

@tott did you have an example for this?

#10 @helen
10 years ago

A lot of this can be mitigated now because you can pass in term_taxonomy_ids yourself, avoiding that particular transform. Trickier if you want to include children, though.

#11 @boonebgorges
10 years ago

  • Keywords needs-patch needs-unit-tests added; has-patch removed

Putting filters on SQL strings is not great for forward compatibility. If the root problem is that the underlying queries are not cached, then WordPress should cache them.

#12 @boonebgorges
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Given the lack of movement on this ticket, and given the fact that it'll be irrelevant once #30262 happens and transform_query() goes away, let's close this.

Note: See TracTickets for help on using tickets.