2013-12-17 52 views
2

前幾天我們將企業升級到1.13.1,以充分利用新的索引系統,但是一種類型的查詢使我們的操作非常緩慢 - 索引,類別保存和產品保存全部觸發此類型的查詢在某個點:將Magento升級到1.13.1後出現問題查詢

INSERT IGNORE INTO `catalog_category_product_index_tmp` (`category_id`, `product_id`, `position`, `is_parent`, `store_id`, `visibility`) SELECT `cc`.`entity_id` AS `category_id`, `ccp`.`product_id`, ccp.position + 10000 AS `position`, 0 AS `is_parent`, 1 AS `store_id`, IFNULL(cpvs.value, cpvd.value) AS `visibility` FROM `catalog_category_entity` AS `cc` 
INNER JOIN `catalog_category_entity` AS `cc2` ON cc2.path LIKE CONCAT(`cc`.`path`, '/%') AND cc.entity_id NOT IN (1) 
INNER JOIN `catalog_category_product` AS `ccp` ON ccp.category_id = cc2.entity_id 
INNER JOIN `catalog_product_website` AS `cpw` ON cpw.product_id = ccp.product_id 
INNER JOIN `catalog_product_entity_int` AS `cpsd` ON cpsd.entity_id = ccp.product_id AND cpsd.store_id = 0 AND cpsd.attribute_id = 96 
LEFT JOIN `catalog_product_entity_int` AS `cpss` ON cpss.entity_id = ccp.product_id AND cpss.attribute_id = cpsd.attribute_id AND cpss.store_id = 1 
INNER JOIN `catalog_product_entity_int` AS `cpvd` ON cpvd.entity_id = ccp.product_id AND cpvd.store_id = 0 AND cpvd.attribute_id = 102 
LEFT JOIN `catalog_product_entity_int` AS `cpvs` ON cpvs.entity_id = ccp.product_id AND cpvs.attribute_id = cpvd.attribute_id AND cpvs.store_id = 1 
INNER JOIN `catalog_category_entity_int` AS `ccad` ON ccad.entity_id = cc.entity_id AND ccad.store_id = 0 AND ccad.attribute_id = 51 
LEFT JOIN `catalog_category_entity_int` AS `ccas` ON ccas.entity_id = cc.entity_id AND ccas.attribute_id = ccad.attribute_id AND ccas.store_id = 1 WHERE (cpw.website_id = '1') AND (IFNULL(cpss.value, cpsd.value) = 1) AND (IFNULL(cpvs.value, cpvd.value) IN (4, 2)) AND (IFNULL(ccas.value, ccad.value) = 1) AND (`cc`.`entity_id` >= '1') AND (`cc`.`entity_id` < 501) 

這可能需要長達30分鐘才能完成。 這是要麼表或INSERT IGNORE INTO catalog_category_product_cat_tmp

我們有大約80.000類別,這可能會導致一個問題,但我們當然不是世界上唯一的商店這麼多。

當在MySQL中做SHOW PROFILE時,它說它卡在Sending data

有沒有人有過這方面的經驗?是否有任何索引可以添加到表中以使此更快捷?以任何方式查看查詢的哪一部分是實際的瓶頸?

回答

1

不容易的解決方案 - 最終重寫索引器。

+0

有什麼方法可以查看您重寫的索引器嗎?你介意共享/銷售它嗎?謝謝。 – Greendrake

+0

問這個人,他做到了:http://stackoverflow.com/users/465971/ivan-chepurnyi – srgb