Slow performance with depth filter on larger site

Created on 27 March 2023, over 2 years ago

Problem/Motivation

I am using the module on larger ecommerce site. I use it to display products on taxonomy pages which are shop categories. After import of larger catalog (about 30000 products) I noticed that category pages are very slow. At least for the first load. After caching it's quite fine.
But for first time load it can take more that 5 seconds to load.
This slow performance is only when using with depth option. So when I want to show products which belongs to current category and all subcategories. When I disable depth option and only display products from current category the performance is fine

Steps to reproduce

Create view and apply contextual filter to display only entities belonging to taxonomy term with depth.

Proposed resolution

I don't know if there is some option to optimise query but it would be very welcomed.

πŸ› Bug report
Status

Active

Version

1.14

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sakonn
  • Status changed to Postponed: needs info over 2 years ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    @sakonn thanks for taking the time to report this.

    Are you able to get a copy of the query from e.g. the views preview with SQL debugging turned on from the views settings?

    If so, can you provide an explain for it?

  • Status changed to Active 3 months ago
  • πŸ‡¨πŸ‡³China lawxen

    I got the same problem, Detail:

    SELECT node_field_data.langcode AS node_field_data_langcode, taxonomy_term_field_data_node__department.langcode AS taxonomy_term_field_data_node__department_langcode, node_field_data.published_at AS node_field_data_published_at, node_field_data.nid AS nid, taxonomy_term_field_data_node__department.tid AS taxonomy_term_field_data_node__department_tid
    FROM
    {node_field_data} node_field_data
    LEFT JOIN {node__department} node__department ON node_field_data.nid = node__department.entity_id AND node__department.deleted = '0' AND (node__department.langcode = node_field_data.langcode OR node__department.bundle = 'article')
    LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_node__department ON node__department.department_target_id = taxonomy_term_field_data_node__department.tid
    INNER JOIN {node__category} node__category ON node_field_data.nid = node__category.entity_id AND node__category.deleted = '0' AND (node__category.langcode = node_field_data.langcode OR node__category.bundle = 'article')
    WHERE (((node__category.category_target_id IN('10', '34333', '24', '23', '26', '19', '18', '27', '16', '13', '17', '14', '25', '48', '15', '20'))) AND (node_field_data.nid IN (SELECT tn.nid AS nid
    FROM
    {taxonomy_index} tn
    LEFT OUTER JOIN {taxonomy_term__parent} th ON th.entity_id = tn.tid
    LEFT OUTER JOIN {taxonomy_term__parent} th1 ON th.parent_target_id = th1.entity_id
    LEFT OUTER JOIN {taxonomy_term__parent} th2 ON th1.parent_target_id = th2.entity_id
    WHERE (tn.tid = '1263') OR (th1.entity_id = '1263') OR (th2.entity_id = '1263'))) AND (node_field_data.trash = '0')) AND ((node_field_data.status = '1') AND (node_field_data.type IN ('article')) AND (node_field_data.promote = '1'))
    ORDER BY node_field_data_published_at DESC
    LIMIT 9 OFFSET 0

    After Delete the contextual filter, the speed faster several times.

    SELECT node_field_data.langcode AS node_field_data_langcode, taxonomy_term_field_data_node__department.langcode AS taxonomy_term_field_data_node__department_langcode, node_field_data.published_at AS node_field_data_published_at, node_field_data.nid AS nid, taxonomy_term_field_data_node__department.tid AS taxonomy_term_field_data_node__department_tid
    FROM
    {node_field_data} node_field_data
    LEFT JOIN {node__department} node__department ON node_field_data.nid = node__department.entity_id AND node__department.deleted = '0' AND (node__department.langcode = node_field_data.langcode OR node__department.bundle = 'article')
    LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_node__department ON node__department.department_target_id = taxonomy_term_field_data_node__department.tid
    INNER JOIN {node__category} node__category ON node_field_data.nid = node__category.entity_id AND node__category.deleted = '0' AND (node__category.langcode = node_field_data.langcode OR node__category.bundle = 'article')
    WHERE (((node__category.category_target_id IN('10', '34333', '24', '23', '26', '19', '18', '27', '16', '13', '17', '14', '25', '48', '15', '20'))) AND ((node__department.department_target_id IN('1263', '70', '25981', '76', '116', '117', '62', '105', '72', '103', '78', '91', '99', '31431', '35625', '22973', '106', '75', '97', '126', '82', '83', '22968', '118', '80', '115', '22967', '69', '85', '108', '67', '95', '25606', '122', '92', '84', '114', '100', '65', '22972', '22257', '74', '66', '73', '119', '109', '124', '96', '64', '71', '107', '68', '104', '63', '90', '88'))) AND (node_field_data.trash = '0')) AND ((node_field_data.status = '1') AND (node_field_data.type IN ('article')) AND (node_field_data.promote = '1'))
    ORDER BY node_field_data_published_at DESC
    LIMIT 9 OFFSET 0
Production build 0.71.5 2024