Skip to content

Every product being queried by WP_Term_Query->get_terms() on every page load. #2207

@10twebdesign

Description

@10twebdesign

I noticed a site really getting slowed with slow queries. After investigating, I noticed that on every page, post, product, a query of...

SELECT t., tt., tr.object_id
FROM agsterms AS t
INNER JOIN agsterm_taxonomy AS tt
ON t.term_id = tt.term_id
INNER JOIN agsterm_relationships AS tr
ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('product_tag', 'wpsc_product_category', 'wpsc-variation')
AND tr.object_id IN (85830, ..., ..., ...) ORDER BY t.name ASC

...where the ids in tr.object_id IN (85830, ..., ..., ...) were all of the ids of every published wpsc_product.

So, essentially, for every single front end page load, every single product along with tax information is being queried and loaded for some reason, even if the page isn't displaying any products. (I though it was just this site, but it's happening on another site I have access to as well, but isn't causing any noticeable slow down, as there's only 40 products or so, with basically no variations.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions