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;
Comment