Support » Fixing WordPress » Deleting terms with many posts very slow

  • I’ve got a custom taxonomy set up on WooCommerce Products via a plugin. It does not appear to use any hooks surrounding the term delete function.
    – There are about 900 terms in a heirarchy
    – There are thousands of products
    – Each term is associated with between 100 and 300 products.

    When I delete a term, it takes a good 5-10 minutes. This is on a dedicated VPS with SSD IO and MariaDB 10, running PHP 7.1. Nothing about the site runs slowly except for this function. If I delete it singularly (via the built in ajax method) and refresh the page repeatedly I can see the process steadily removing the associated products from the term before it *finally* deletes it.

    During the course of this there is a PHP process at 100% CPU most of the time, but MariaDB is humming along quietly, barely interrupted. mysqladmin processlist tells me the queries are mostly sleeping / waiting for processing to occur elsewhere — the bottleneck does not appear to be SQL.

    Clearly based on what I’m seeing, the performance issues are in removing the products from the term using wp_set_object_terms( $object_id, $terms, $taxonomy ); found here.

    This very old trac thread indicates that this is a known issue and was closed because the devs considered it ‘fixed well enough’, but I think in the days of WooCommerce and regularly having thousands of products and large datasets relying on this code, I don’t think that’s sufficient. There are suggestions in that trac thread about improving this using SQL rather than PHP and they say they’re waiting on the lack of MySQL4 — I’d say we’ve come far enough to implement some of those suggested changes.

    Hoping others might have some thoughts on this.

    • This topic was modified 1 year, 5 months ago by jas8522.
Viewing 2 replies - 1 through 2 (of 2 total)
  • IS this caused by WordPress or WooCommerce code?

    I’m fairly confident it’s WordPress code — specifically wp_set_object_terms() being used to remove a term from post objects rather than via direct database query, but I haven’t yet done enough testing to say with absolute certainty.

    • This reply was modified 1 year, 5 months ago by jas8522.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Deleting terms with many posts very slow’ is closed to new replies.