Performance improvements. Minimize the number of SQL queries.

Created on 29 November 2024, 22 days ago

Problem/Motivation

We're encountering performance challenges with this module when applied to extensive taxonomies.
The idea is to reduce the number of SQL queries that the module sends to the database when building the hierarchy terms tree.

Steps to reproduce

- Create a taxonomy hierarchy with two or more levels containing thousands of terms.
- Use any profiling tool you're familiar with to get an understanding of the number of SQL queries that the term_reference_tree module produces(one of the possible solutions is to check it via the webprofiler Drupal module).

Proposed resolution

I’ve tried to minimize the number of queries we send by using the max_depth setting we already have in the widget settings.
As I see now, the module sends requests even if these “sub-level “ elements are not outputted later in the template.

So we can use the value set in the "Maximum Depth" form field widget to stop the _term_reference_tree_get_term_hierarchy recursion if we don't need to get the nested items even if they exist.

This is not a complete solution and does not fully resolve the performance issues with large datasets. However, it can be seen as a step toward improving performance.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany kufliievskyi Germany, Bayern

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024