Skip to content

A lot of repeated sql select queries are fired #169

@adhocore

Description

@adhocore

probably in these steps:

general/general/global-data > general/catalog_product/collect-data
SHOW GLOBAL VARIABLES LIKE 'innodb%';
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (3);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (3);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (4);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (3);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (4);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (5);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (3);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (4);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (6);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (3);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (4);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (7);
SELECT t1.* FROM catalog_category_entity AS t0 INNER JOIN catalog_category_entity_varchar AS t1 ON t1.row_id = t0.row_id INNER JOIN eav_attribute AS t2 ON t2.entity_type_id = 3 AND t2.attribute_code = 'name' AND t1.attribute_id = t2.attribute_id AND t1.store_id = 0 AND t0.entity_id IN (2);

and for a 2-3 rows simple product import, there are easily 3000+ sqls queries making everything slower than it should have been.

PS: using redis as a cache doesnt seem to help either.

My guess is: it could be N+1 problem compounded. For each new category it sends query for older category.

For context:
Magento = 2.3.3 EE
entityTypeCode = catalog_product
shortcut = add-update

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions