2

I have a vocabulary with around 15k+ terms in multi-level hierarchies. Recently I noticed that with this amount of data, when I try to save a term of a higher level (parent to many), it takes a lot of time to save.

I checked with the webprofiler module and saw there was around 10k queries running for such a single term including the queries it is running for it's children. I am not sure if this is expected, but is there a way I can speed up the process? These queries includes tables like cache, path_alias, taxonomy_term_data, taxonomy_term_revision, key_value etc.

I have tried applying memcached that considerably reduces the queries, specially from the cache tables, but still the child term queries are run slowing down the process.

I also considered running the process in background, but in that case also, it supposedly should take the same amount of server resources. The problem is so much so that my entire application is going into a halt state (sometimes unavailable) when I am updating some terms through a drush command.

Any help?

2
  • Do you have this issue when saving just one term via the UI? Or are you only seeing the issue when running a drush command that is updating many terms?
    – sonfd
    Commented Jul 9, 2021 at 20:27
  • I have this issue in any and every place I try to save a term. Be it from ui or programmatically. The higher the term in hierarchy, the more time it takes. Commented Jul 11, 2021 at 0:33

1 Answer 1

2

I found the reason from where the problem is originating. It is from the pathauto module which has an entity update hook that loads all the children every time a taxonomy term is being saved. It is done to update the children's alias along with the parent that is being saved. I am thinking of opening a ticket in their issue queue. The idea should be to update the child aliases only when their is a dependency on the a parent attribute. Like /term/[parent-term-name]/[child-term-name]. Not only that, it should ideally be processed in a queue worker with a transaction lock maybe. Hope this helps somebody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.