当我修改属于捆绑包的 Magento 1.7.0.2 简单产品时,有时我会收到错误消息:
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away.
在 mysql.slowquery.log 中出现了这个可怕的查询:
Query_time: 30.408723 Lock_time: 0.000463 Rows_sent: 0 Rows_examined: 128
SET timestamp=1353399962;
INSERT INTO `catalog_product_index_price_bundle_tmp` SELECT `e`.`entity_id`, `cg`.`customer_group_id`, `cw`.`website_id`, 0 AS `tax_class_id`, 0 AS `price_type`, IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) <= cwd.website_date, 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) >= cwd.website_date, 1, 0)) > 0 AND ta_special_price.value > 0 AND ta_special_price.value < 100 , ta_special_price.value, 0) AS `special_price`, tp.min_price AS `tier_percent`, IF(ta_price.value IS NULL, 0, ta_price.value) AS `orig_price`, 0 AS `price`, 0 AS `min_price`, 0 AS `max_price`, IF(tp.min_price IS NOT NULL, 0, NULL) AS `tier_price`, IF(tp.min_price IS NOT NULL, 0, NULL) AS `base_tier`, IF(IF(gp.price IS NOT NULL AND gp.price > 0 AND gp.price < 100, gp.price, 0) > 0, IF(gp.price IS NOT NULL AND gp.price > 0 AND gp.price < 100, gp.price, 0), NULL) AS `group_price`, IF(IF(gp.price IS NOT NULL AND gp.price > 0 AND gp.price < 100, gp.price, 0) > 0, IF(gp.price IS NOT NULL AND gp.price > 0 AND gp.price < 100, gp.price, 0), NULL) AS `base_group_price`, gp.price AS `group_price_percent` FROM `catalog_product_entity` AS `e`
CROSS JOIN `customer_group` AS `cg`
CROSS JOIN `core_website` AS `cw`
INNER JOIN `core_store_group` AS `csg` ON csg.group_id = cw.default_group_id
INNER JOIN `core_store` AS `cs` ON cs.store_id = csg.default_store_id
INNER JOIN `catalog_product_website` AS `pw` ON pw.product_id = e.entity_id AND pw.website_id = cw.website_id
INNER JOIN `catalog_product_index_website` AS `cwd` ON cw.website_id = cwd.website_id
LEFT JOIN `catalog_product_index_tier_price` AS `tp` ON tp.entity_id = e.entity_id AND tp.website_id = cw.website_id AND tp.customer_group_id = cg.customer_group_id
LEFT JOIN `catalog_product_index_group_price` AS `gp` ON gp.entity_id = e.entity_id AND gp.website_id = cw.website_id AND gp.customer_group_id = cg.customer_group_id
INNER JOIN `catalog_product_entity_int` AS `tad_status` ON tad_status.entity_id = e.entity_id AND tad_status.attribute_id = 89 AND tad_status.store_id = 0
LEFT JOIN `catalog_product_entity_int` AS `tas_status` ON tas_status.entity_id = e.entity_id AND tas_status.attribute_id = 89 AND tas_status.store_id = cs.store_id
LEFT JOIN `catalog_product_entity_int` AS `tad_tax_class_id` ON tad_tax_class_id.entity_id = e.entity_id AND tad_tax_class_id.attribute_id = 115 AND tad_tax_class_id.store_id = 0
LEFT JOIN `catalog_product_entity_int` AS `tas_tax_class_id` ON tas_tax_class_id.entity_id = e.entity_id AND tas_tax_class_id.attribute_id = 115 AND tas_tax_class_id.store_id = cs.store_id
INNER JOIN `catalog_product_entity_int` AS `ta_price_type` ON ta_price_type.entity_id = e.entity_id AND ta_price_type.attribute_id = 117 AND ta_price_type.store_id = 0
LEFT JOIN `catalog_product_entity_decimal` AS `ta_price` ON ta_price.entity_id = e.entity_id AND ta_price.attribute_id = 69 AND ta_price.store_id = 0
LEFT JOIN `catalog_product_entity_decimal` AS `ta_special_price` ON ta_special_price.entity_id = e.entity_id AND ta_special_price.attribute_id = 70 AND ta_special_price.store_id = 0
LEFT JOIN `catalog_product_entity_datetime` AS `tad_special_from_date` ON tad_special_from_date.entity_id = e.entity_id AND tad_special_from_date.attribute_id = 71 AND tad_special_from_date.store_id = 0
LEFT JOIN `catalog_product_entity_datetime` AS `tas_special_from_date` ON tas_special_from_date.entity_id = e.entity_id AND tas_special_from_date.attribute_id = 71 AND tas_special_from_date.store_id = cs.store_id
LEFT JOIN `catalog_product_entity_datetime` AS `tad_special_to_date` ON tad_special_to_date.entity_id = e.entity_id AND tad_special_to_date.attribute_id = 72 AND tad_special_to_date.store_id = 0
LEFT JOIN `catalog_product_entity_datetime` AS `tas_special_to_date` ON tas_special_to_date.entity_id = e.entity_id AND tas_special_to_date.attribute_id = 72 AND tas_special_to_date.store_id = cs.store_id WHERE (e.type_id='bundle') AND (IF(IFNULL(tas_status.value_id, -1) > 0, tas_status.value, tad_status.value)=1) AND (ta_price_type.value=0) AND (e.entity_id IN(2399, 2400, 2401, 2402)) ON DUPLICATE KEY UPDATE `tax_class_id` = VALUES(`tax_class_id`), `price_type` = VALUES(`price_type`), `special_price` = VALUES(`special_price`), `tier_percent` = VALUES(`tier_percent`), `orig_price` = VALUES(`orig_price`), `price` = VALUES(`price`), `min_price` = VALUES(`min_price`), `max_price` = VALUES(`max_price`), `tier_price` = VALUES(`tier_price`), `base_tier` = VALUES(`base_tier`), `group_price` = VALUES(`group_price`), `base_group_price` = VALUES(`base_group_price`), `group_price_percent` = VALUES(`group_price_percent`);
在数据库中,表catalog_product_index_price_bundle_tmp为空。
谢谢。