Score:2

Taxonomy term save very slow

ae flag

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?

sonfd avatar
in flag
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?
ae flag
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.
Score:2
ae flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.