Announcement

Collapse
No announcement yet.

Indexes setting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Indexes setting

    Hello there, could you advice me what indexes should I set to speed up query which list products. It takes 30s.
    • Account: 5900 rows
    • Product: 2300 rows
    • Attachments: 26176 rows


    Code:
    SELECT product.id AS `id`, product.created_by_id AS `createdById`, product.cover_image_id AS `coverImageId`, coverImage.name AS `coverImageName`, product.quote_score AS `quoteScore`, product.part_number AS `partNumber`, product.cust_part_num AS `custPartNum`, product.name AS `name`, product.account_id AS `accountId`, account.name AS `accountName`, product.product_type AS `productType`, product.created_at AS `createdAt`, product.own_part_number AS `ownPartNumber` FROM `product` LEFT JOIN `attachment` AS `coverImage` ON product.cover_image_id = coverImage.id LEFT JOIN `account` AS `account` ON product.account_id = account.id WHERE product.category_id IS NULL AND product.deleted = 0 ORDER BY product.own_part_number DESC, product.id DESC LIMIT 0, 51;
    Click image for larger version

Name:	idx.jpg
Views:	161
Size:	74.0 KB
ID:	78050

    Click image for larger version

Name:	explain.jpg
Views:	166
Size:	63.1 KB
ID:	78051

    Click image for larger version

Name:	account_idx.jpg
Views:	167
Size:	48.3 KB
ID:	78052

    Click image for larger version

Name:	att_idx.jpg
Views:	174
Size:	92.8 KB
ID:	78053
    Attached Files

  • #2
    Espo version? Maybe collumns collations issue?

    Comment


    • #3
      In older installations, there is a problem with collision mismatch between fields within tables. As a result, there are performance problems, in particular, the newly added fields of the image type have the utf8_unicode_ci id in the attachment and utf8mb4_unicode_ci in the image_id field in the entity. I believe that the

      Comment


      • #4
        Yes, thank you, it was it. There was ID on joined tables collation utf8_unicode_ci but entity_id in FROM table was utf8mb4_unicode_ci. Now it take aproximatly 10 ms.

        Just remark, before I run 6.1.14, than I tried to upgrade to 7.0.8 and speed was the same. I am with EspoCRM since 5.3.6 so may be during upgrades there was some adjust of collation in structure or when I migrate from one server to another I don't know how it was happened.
        Last edited by Jakub; 01-08-2022, 10:55 AM.

        Comment

        Working...
        X