• Hi, my on my store I’m using Query Monitor and on product pages it shows over 100 slow queries. And because of that my load time are over 30 seconds or more. I asked my hosting provider (A2 Hosting) about it and they confirmed that there is no problem on their side and this may be plugin problem. The queries that are slow looks like this:

    SELECT t.*, tt.*
    FROM wp_terms AS t
    INNER JOIN wp_term_taxonomy AS tt
    ON t.term_id = tt.term_id
    INNER JOIN wp_term_relationships AS tr
    ON tr.term_taxonomy_id = tt.term_taxonomy_id
    WHERE tt.taxonomy IN (‘product_shipping_class’)
    AND tr.object_id IN (878)
    ORDER BY t.name ASC

    and

    SELECT DISTINCT t.*, tt.*, tm.meta_value
    FROM wp_terms AS t
    INNER JOIN wp_term_taxonomy AS tt
    ON t.term_id = tt.term_id
    INNER JOIN wp_term_relationships AS tr
    ON tr.term_taxonomy_id = tt.term_taxonomy_id
    LEFT JOIN wp_termmeta AS tm
    ON (t.term_id = tm.term_id
    AND tm.meta_key = ‘order’)
    WHERE tt.taxonomy IN (‘product_cat’)
    AND tr.object_id IN (828)
    ORDER BY tm.meta_value+0 ASC, t.name ASC

    and both are called by:
    WP_Term_Query->get_terms()
    wp-includes/class-wp-term-query.php:695

    I tried to delete the function from class-wp-term-query.php from line 695 to 698 and site loading speed was great but it doesn’t look how it should look.

    I’m adding some images maybe it helps:

    https://prntscr.com/fnxujj
    https://prntscr.com/fnxuv0
    https://prntscr.com/fnxvne
    https://prntscr.com/fnxvxc
    https://prntscr.com/fnxz57
    https://prntscr.com/fnxzbd

    WordPress version: 4.8
    Woocommerce version: 3.0.9
    Active plugins: 19
    Products: 55
    PHP version: 7.0
    Server cores: 2 x 2.1Ghz
    RAM: 1 GB
    Theme: Flatsome
    Site link: https://macoutlet.store

    Maybe anyone had similar problem and know any possible solution to fix it. This is the first time when I ask something so if anyone needs any more information I will try to provide it.

Viewing 1 replies (of 1 total)
  • I tried to delete the function from class-wp-term-query.php from line 695 to 698

    Never modify or delete core WordPress files. You’re only going to break your site if you start doing that.

    I don’t see anything in those queries that would make them unusually slow. They just look like the normal queries to get categories for a product. Does this product have a particularly large amount of categories? Or do the categories have a lot of custom meta fields on them? These are things I’d check.

    If that doesn’t answer the problem, try deactivating all plugins except WooCommerce and see if that improves the speed of the queries.

    Also make sure to test how fast the page actually loads. The queries could be ‘slow’ by SQL standards, but might not be actually affecting the perceived load speed of your pages. Take the “Slow queries” as something to look into, but don’t worry if it’s not actually affecting anything tangible about your site.

    If none of that helps it could just be that the performance of your host isn’t up to snuff. WooCommerce can be pretty beefy if you’ve got a lot of content. In this case there might not be anything ‘wrong’ with your hosting that can be fixed. You might just need to find one that’ll give you something a bit more powerful.

Viewing 1 replies (of 1 total)
  • The topic ‘Slow queries class-wp-term-query’ is closed to new replies.