Skip Navigation

[Resolved] Huge hierarchical taxonomy works slow – what to do? (hierarchy is mandatory)

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2186747

BV

Hello!

I have now about 35000 taxonomy terms in hierarchy and hierarchy is necessary here - it's the location pages in the directory. Most of them even empty, but they still necessary - coz their term archive pages works as location pages.

I have super strong caching on different levels - from Mysql - via Redis - Opcache - WP Rocket - Cloudflare.

But there are still pitfals related to edit or initial requesting of some slow pages.

For example, I found that the close to the root taxonomy archives are making crazy requests with ids of all children - like "AND ( wp_term_relationships.term_taxonomy_id IN (6,17,21,31,41,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,…) etc, thousands of term ids there.

Is there a way to easy fix such a worse architecture? I saw the recommendation not to use hierarchical taxonomies, but I needed hierarchy. And I use most native taxonomy features, such as archives and lists of terms with numbers of posts inside.

#2186943

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2021-10-04 at 15.59.29.png

Unfortunately that's a WordPress thing.

If you create a custom archive with Toolset that doesn't add anything, e.g. custom filters, then you are just customising the output of the results returned by the archive query, not changing the underlying query itself.

You can see in the screenshot an example where Toolset Views/Blocks have been disabled and are not responsible for the archive, where the Main Query shown is that generated by WordPress itself.

This is only a small test site, but the structure of the query is the same as you describe above.

#2186953

BV

Yeah, I understand that it's the core WP issue. But I ask you, because one of the cases of Toolset uses is directory. Maybe you have some recommendations/ideas/etc? I suppose one of that can be, maybe, related posts, but with a big amount of coding in custom templates or, even, real coding.

#2186955

BV

Yeah, I understand, and I understand it's the core WP issue, but maybe you had experience with redesigning of websites with such issue or have just ideas on what possible to do.

#2187429

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

Unfortunately, there is no simple workaround available for this. Toolset makes use of WordPress queries and builds up its own features on top of that. Therefore, if WordPress performs a query operation in a certain way, it won't be possible to bypass that completely.

I wouldn't recommend adopting the structure of a related post, over the current hierarchal taxonomy setup, because:

1. In WordPress, taxonomy filtering is optimized and it will be more efficient, compared to filtering by related posts.

2. Features that you need like archives and lists of terms with numbers of posts inside, are available natively, whereas, in the case of related posts, you'll need to add them using views and custom code, which will increase the number of queries, instead of simplifying them.

Based, on the available options and the requirement that you've shared, I can't think of a better alternative than the current hierarchal taxonomy setup.

#2189709

BV

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.